functions inside or outside jquery document ready

前端 未结 5 1201
迷失自我
迷失自我 2020-11-28 04:17

Up until now I just put all my jQuery goodness inside the $(document).ready() function, including simple functions used in certain user interactions.

B

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-28 04:49

    one advantage of putting those functions inside the document ready function is that they don't pollute your global namespace... with the downside that if you need them somewhere else on the page they won't be available.

提交回复
热议问题