简体   繁体   中英

jQuery mobile - Trigger event when user scroll to specific element

I'm trying to detect when user scroll to specific div element with class .seller-info but scrollTop() method always returns 0

I've tried all of the examples here in stack, but still not working. Here's my latest solution:

$('body').on({
    'touchmove': function(e) {
     console.log($(this).scrollTop());
    }
});

Any ideas how could i detect it ?

I think Its helps to you

 $(window).scroll(function() { var hT = $('#scroll-to').offset().top, hH = $('#scroll-to').outerHeight(), wH = $(window).height(), wS = $(this).scrollTop(); console.log((hT-wH) , wS); if (wS > (hT+hH-wH)){ alert('scroll reached!'); } }); 
 div { height:400px; background:green; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div>Scroll Down</div> <h1 id="scroll-to">I am The H1</h1> 

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