我試圖將所有內容都包含在名爲bodySemex的div的<body>
標籤中。對於大多數頁面,這工作得很好:在某些頁面上使用wrapAll()的奇怪行爲
$('body').children().wrapAll('<div id="bodySemex" />')
然而,在一些網頁上,這會導致人體元素完全消失。 (例如,avc.com和http://www.theatlantic.com/technology/archive/12/07/how-the-gorgeous-sometimes-fictional-sound-of-the-olympics-gets-made/259742/都消失了,因爲這行代碼的結果
我得到一個錯誤信息的每個發生這種情況時;似乎消息表明,jQuery的each()
功能正試圖在東西是操作。未定義
Uncaught ReferenceError: _gat is not defined
(anonymous function)
e.extend.globalEval chrome-extension://clcjngnadninklpbdkjccpoenjdomnid/js/jquery.js:2
e.extend.globalEval chrome-extension://clcjngnadninklpbdkjccpoenjdomnid/js/jquery.js:2
bp chrome-extension://clcjngnadninklpbdkjccpoenjdomnid/js/jquery.js:2
e.extend.each chrome-extension://clcjngnadninklpbdkjccpoenjdomnid/js/jquery.js:2
f.fn.extend.domManip chrome-extension://clcjngnadninklpbdkjccpoenjdomnid/js/jquery.js:4
f.fn.extend.prepend chrome-extension://clcjngnadninklpbdkjccpoenjdomnid/js/jquery.js:3
f.each.f.fn.(anonymous function) chrome-extension://clcjngnadninklpbdkjccpoenjdomnid/js/jquery.js:4
(anonymous function) chrome-extension://clcjngnadninklpbdkjccpoenjdomnid/js/distillery.js:365
e.extend.each chrome-extension://clcjngnadninklpbdkjccpoenjdomnid/js/jquery.js:2
e.fn.e.each chrome-extension://clcjngnadninklpbdkjccpoenjdomnid/js/jquery.js:2
bodySwap (Note, this is the name of the line of code the this question is about)
我已搜查SO類似的問題,並嘗試了一些替代wrapAll(例如,替代這裏討論:Jquery wrapAllInner() ? -- Or wrapAll() applied interally?)
感謝您的幫助,您可以提供
!