jQuery document.ready vs pageLoad

后端 未结 6 1720
陌清茗
陌清茗 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:26

    $(document).ready()

    • Ideal for one time initialization.

    • Optimization black magic; may run slightly earlier than pageLoad().

    • Does not re-attach functionality to elements affected by partial postbacks.

    pageLoad()

    • Unsuitable for one time initialization if used with UpdatePanels.

    • Slightly less optimized in some browsers, but consistent.

    • Perfect for re-attaching functionality to elements within UpdatePanels.

提交回复
热议问题