简体   繁体   中英

jQuery animate scrolltop() not scrolling downwards in IE10

When I apply this code and test this in Internet Explorer and FireFox, on click, the page does not scroll down with the toggle function, but it does scroll back up after closing the overlay. This works fine in Google Chrome, but not in IE 10 or Firefox. Please help. :)

  $(document).ready(function(){


 $(".PlaceHolders").click(function(e){

e.preventDefault();
$(".overlay").slideToggle(2000, function(){

  $("#url_placeholder").text($(this).is(':visible') ? "Close Components" : "View Available Components");
});
   $('html','body').animate({scrollTop: $(".PlaceHolders").offset().top}, 2000);
 });

It's just your selector. See http://codepen.io/anon/pen/MYNZzW

   $('html,body').animate({scrollTop: $(".PlaceHolders").offset().top}, 2000);

hope this is what you had wanted. Here's a working fiddle, tested in chrome and ie10,

$(document).ready(function(){

 $(".PlaceHolders").click(function(e){

$(".overlay").slideToggle("slow", function() {

 setTimeout(function(){
   $("#url_placeholder").text($(this).parent(".overlay").is(':visible') ? "Close Components" : "View Available Components");
  },500);
  });

  $("html, body").animate({ scrollTop: $("#url_placeholder").offset().top }, 1000);

e.preventDefault();
});

});

http://jsfiddle.net/adhegde001/8uf9pvqw/1/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM