Copy codeThe Code is as follows:
<BR> ****************/
Function scrollLoading (){
Var st = $ (window). scrollTop (), something = st + $ (window). height ();
Var $ targetpics = $ ("img. scrloadpic ");
Var len = $ targetpics. length;
For (var I = 0; I <len; I ++)
{
Var $ temppic = $ targetpics. eq (I );
Var post = $ temppic. position (). top;
Var posb = post + $ temppic. height ();
If (post> st & post <TH) | (posb> st & posb <TH ))
{
Var url = $ temppic. attr ("xsrc ");
If (url! = "")
{
$ Temppic. attr ("src", url );
$ Temppic. attr ("xsrc ","");
}
}
}
}
The above is a function that implements rolling loading. In the html code below, you need to add an xsrc attribute in img to temporarily store the path of the real image. In src, the path of the loading image is stored, add a class named "scrloadpic" to each image to implement this function.
Copy codeThe Code is as follows:
Finally, call the function.
Copy codeThe Code is as follows:
ScrollLoading ();
$ (Window). bind ("scroll", scrollLoading );