Delay some jQuery function until all images are loaded completely

后端 未结 2 635
没有蜡笔的小新
没有蜡笔的小新 2021-01-24 08:05

How do I delay some jQuery / JavaScript function until all the images on a page have finished loading? Actually, the jQuery function I\'m talking about is for setting the offset

2条回答
  •  伪装坚强ぢ
    2021-01-24 08:37

    just write the function under a variable like

    function newfunction(){
    //put all the stuff here
    }
    

    after that call this function on every image load like

    $('img').load(function(){
    newfunction()
    })
    

    from this the newfunction will call everytime a new image load.

提交回复
热议问题