jQuery document.ready vs pageLoad

后端 未结 6 1705
陌清茗
陌清茗 2021-02-02 11:56

I\'ve picked up an existing project from another developer and ive noticed in the code that they are executing js code within three different event handlers...

f         


        
6条回答
  •  遥遥无期
    2021-02-02 12:24

    $(document).ready(function() {
    `enter code here`
    //execute code
    });
    
    $(function() {
    `enter code here`
    });
    

    Both functions perform task in the same way, executes code inside them once the document is ready.

    function pageLoad() {
    `enter code here`
    }
    

    This executes after every post back, generally used with update panels controls as the above two functions does not execute every time or every post back.

提交回复
热议问题