Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
37
rated 0 times [  44] [ 7]  / answers: 1 / hits: 20948  / 9 Years ago, fri, june 19, 2015, 12:00:00

I am working on single page asp.net-mvc5 application....



I have a hidden div in my code, i tried to show this div on ajax success but failed...How can i achieve that, am i doing it right???




Before putting Display:None, animate function was working fine on
success, now its not working also due to hidden nature i guess...




HTML



<section class=block remove-top id=contact-us style=display: none;>
<form method=post action= name=contactform id=contactform>
<div class=row>
<input name=FirstName type=text id=FirstName/>
<input type=submit class=submit id=btnSubmit value=Submit />
</form>
</section>


Ajax



<script>
function packageSelect(PackageId) {
$.ajax({
type: POST,
url: '@Url.Action(SelectPackage, Home)',
dataType: JSon,
data: { PackageId: PackageId },
success: function (data) {
console.log(data);
//$(#SecondInfo).focus({ scrollTop: 0px });
$('html, body').animate({ scrollTop: $('#contact-us').offset().top }, 'slow');
},
error: console.log(it did not work),
});
};
</script>


Please if someone help, any kind of help will be appreciated....thanks for your time:)


More From » jquery

 Answers
42

show the element before animation.



$('#contact-us').show();

$('html, body').animate({ scrollTop: $('#contact-us').offset().top }, 'slow');


If you want the element to be hidden:



$('#contact-us').show();

$('html, body').animate({ scrollTop: $('#contact-us').offset().top }, 'slow', function() {
$('#contact-us').hide(); // Hide element after scroll is completed
});

[#66140] Wednesday, June 17, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
magaly

Total Points: 524
Total Questions: 96
Total Answers: 89

Location: India
Member since Wed, Aug 26, 2020
4 Years ago
magaly questions
Wed, May 5, 21, 00:00, 3 Years ago
Sun, Nov 8, 20, 00:00, 4 Years ago
Mon, Oct 21, 19, 00:00, 5 Years ago
Mon, Jul 15, 19, 00:00, 5 Years ago
;