我想包裝一些HTML代碼內的div.My代碼是這樣的對象不支持屬性或方法「包裹」在IE 9
$x= $(data).find(list).html().wrap('<div class="new" />');
alert($x);
但這會引發錯誤
Object doesn't support property or method 'wrap'
在IE 9.任何人都可以幫助我。
我想包裝一些HTML代碼內的div.My代碼是這樣的對象不支持屬性或方法「包裹」在IE 9
$x= $(data).find(list).html().wrap('<div class="new" />');
alert($x);
但這會引發錯誤
Object doesn't support property or method 'wrap'
在IE 9.任何人都可以幫助我。
您需要重新排列鏈序列:
$x= $(data).find(list).wrap('<div class="new" />').html();
你的usign包裝爲html代碼...你需要先將它轉換成jquery對象,才能使用jquery的wrap方法。
試試這個
$x= $($d).wrap('<div class="new" />');
出現這種情況,因爲:
$(data).find(list).html()
回報你的第一個元素中的HTML內容匹配元素集或設置每個匹配元素的HTML內容。爲了包裝,你需要一個jQuery對象。
所以,要麼你可以這樣做:
$d= $(data).find(list);
$x= $d.wrap('<div class="new" />').html();
alert($x);
OR
$x= $(data).find(list).wrap('<div class="new" />').html();
alert($x);