mat*_*att 7 ajax jquery scroll reload
我猜你们所有人都熟悉一旦到达页面底部就通过ajax在网站上重新加载元素.
我自己尝试过,但似乎我的脚本被多次触发......
<script type="text/javascript">
$(document).ready(function() {
$(window).scroll(function() {
if ( $(window).scrollTop() + $(window).height() == $(document).height() ) {
myfunctionCall();
Run Code Online (Sandbox Code Playgroud)
知道我怎么能多次阻止这个叫做多次?我想这只会发生在带有"平滑滚动"的Mac上,或者你可能称之为的任何东西.
亲切的问候,马特
一个非常简单的选择是使用变量来存储是否应该调用该函数.
<script type="text/javascript">
$(document).ready(function() {
var callFunction = true;
$(window).scroll(function() {
if ( callFunction && $(window).scrollTop() + $(window).height() == $(document).height() ) {
myfunctionCall();
callFunction = false;
}
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1231 次 |
最近记录: |