javascript - how to show hidden div on ajax success call -
i working on single page asp.net-mvc5 application....
i have hidden div in code, tried show div on ajax success failed...how can achieve that, doing right???
before putting "display:none", animate function working fine on success, not working due hidden nature 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 help, kind of appreciated....thanks time:)
show element before animation.
$('#contact-us').show(); $('html, body').animate({ scrolltop: $('#contact-us').offset().top }, 'slow'); if want element hidden:
$('#contact-us').show(); $('html, body').animate({ scrolltop: $('#contact-us').offset().top }, 'slow', function() { $('#contact-us').hide(); // hide element after scroll completed });
Comments
Post a Comment