javascript - Issues with cross browser compatibility in the following code -
i facing issues in following code. code working fine in firefox, when tried same on chrome, internet explorer 8, opera not working.
following code:
<script type="text/javascript"> $('bodyul').ready(function(){ // checking if @ end of window $(document).scroll(function(){ if ($(window).scrolltop() == $(document).height() - $(window).height()){ loadnewdata(); } }); function loadnewdata(){ alert('loadingnewdata'); (var i=0; i<20; i++){ $('ul').append($('<li>'+new date().gettime()+'</li>')); } } }); </script>
please let me know changes need make in code run in browsers. thanks.
only element matching current document has ready()
method :
$(document).ready(function(){ $(window).on('scroll', function(){ if ( $(window).scrolltop() == ($(document).height() - $(window).height()) ) { loadnewdata(); } }); function loadnewdata(){ (var i=0; i<20; i++){ var li = $('<li />', {text:new date().gettime()}); $('ul').append(li); } } });
Comments
Post a Comment