简体   繁体   English

在我的Web应用程序中滚动

[英]Scrolling in my web application

I need to trigger a scroll event and to a particular y-pos within an element in my web application. 我需要触发滚动事件并触发Web应用程序中某个元素内的特定y-pos。 How will I do that. 我该怎么做。 My element not the entire window and if its the case I can go for window.scrollTo(x, y). 我的元素不是整个窗口,如果可以的话,我可以使用window.scrollTo(x,y)。 My element has the class A. So will the following jquery work? 我的元素具有类A。那么下面的jquery可以工作吗?

$('.A').scrollTo(x,y)

But the above code does not produce the expected o/p. 但是上面的代码无法产生预期的o / p。

I tried the following code after reading gokul shinde: 在阅读gokul shinde之后,我尝试了以下代码:

var scroller = $('.x-grid3-scroller'); 
var scrollerHeight = scroller.height;
 scroller.animate({
        scrollTop: scroller.offset({top:scrollerHeight, left:0})
    },'slow'
 );

still did not work :( 仍然没有用:(

 function scrolTop() { $('html,body').animate({ scrollTop: $(".A").offset().top },'slow' ); } 
 .A { border: 1px solid red; height: 500px; } .B { color: Green; Font-size: 20px; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div> <div class="A"></div> <div class="B" onclick="scrolTop();">Click Here</div> </div> 

This Should help you. 这应该对您有帮助。

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

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