I can't get the LazyLoad plugin to work for me, so I'm trying to write my own. I currently have a list of downloadable images inside a DIV. They are pulled by a PHP query into the mysql database. DIV scrolling is set to auto. The code I'm using is:
<div id="b1" style="overflow:auto;">
<?PHP $result = mysql_query("SELECT * FROM images");
while($row = mysql_fetch_assoc($result)) {
echo "<img src='$row[photo]' style='display:none'> <br>";
}
</div>
<script type="text/javascript">
function imgCheck() {
var position = $("img").offset().top;
var scrollCheck = $("#b1").scrollTop() + $("#b1").height();
if ( scrollCheck > position) {
$("img").fadeIn("fast");
}
$("#b1").scroll( function() { imgCheck() } );
</script>
Although this does not work for me. Can someone help me or shoot some suggestions?
source
share