jQuery $(document).ready () fires twice

前端 未结 13 913
忘了有多久
忘了有多久 2020-11-29 03:13

I\'ve been sifting around the web trying to find out whats going on here and I have not been able to get a concrete answer.

I have one $(document).ready

13条回答
  •  孤街浪徒
    2020-11-29 03:44

    The ready event cannot fire twice. What is more than likely happening is you have code that is moving or manipulating the element that the code is contained within which causes the browser to re-execute the script block.

    This can be avoided by including script tags in the or before the closing tag and not using $('body').wrapInner();. using $('body').html($('body').html().replace(...)); has the same effect.

提交回复
热议问题