简体   繁体   English

jQuery的animate scrolltop()不在IE10中向下滚动

[英]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. 当我应用此代码并在Internet Explorer和FireFox中对其进行测试时,单击时页面不会使用切换功能向下滚动,但是在关闭叠加层后页面会向上滚动。 This works fine in Google Chrome, but not in IE 10 or Firefox. 这在Google Chrome浏览器中工作正常,但在IE 10或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 参见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, 这是一个正在工作的小提琴,经过了chrome和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/ http://jsfiddle.net/adhegde001/8uf9pvqw/1/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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