大佬教程收集整理的这篇文章主要介绍了javascript – 检测div滚动jquery,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
$(document).ready(function() { var track_load = 0; //@R_262_10586@l loaded record group(s) var loading = false; //to prevents multipal ajax loads var @R_262_10586@l_groups = <?php echo $@R_262_10586@l_groups; ?>; //@R_262_10586@l record group(s) $('#results').load("autoload_process.php",{'group_no':track_loaD},function() {track_load++;}); //load first group $(window).scroll(function() { //detect page scroll if($(window).scrollTop() + $(window).height() == $(document).height()) //user scrolled to bottom of the page? { if(track_load <= @R_262_10586@l_groups && loading==falsE) //there's more data to load { loading = true; //prevent further ajax loading $('.animation_image').show(); //show loading image //load data from the server using a http POST request $.post('autoload_process.php',{'group_no': track_loaD},function(data){ $("#results").append(data); //append received data into the element //hide loading image $('.animation_image').hide(); //hide loading image once data is received track_load++; //loaded group increment loading = false; }).fail(function(xhr,ajaxOptions,thrownerror) { //any errors? alert(thrownerror); //alert with http error $('.animation_image').hide(); //hide loading image loading = false; }); } } });
});
这是我的HTML代码.
<div id="scrollingbox"> <ol id="results"> </ol> <div class="animation_image" style="display:none" align="center"><img src="ajax-loader.gif"></div> </div>
我使用了div ID,但是它不输出两个.
这是一个简单的jsfiddle:http://jsfiddle.net/collabcoders/v2RbN/
$(".box").scroll(function() { //.box is the class of the div $("span").css( "display","inline" ).fadeOut( "slow" ); });
更新:http://jsfiddle.net/collabcoders/v2RbN/1/
$("span").hide(); $(".box").scroll(function() { if($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight) { $("span").show(); } else { $("span").hide(); } });
以上是大佬教程为你收集整理的javascript – 检测div滚动jquery全部内容,希望文章能够帮你解决javascript – 检测div滚动jquery所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。