Opened 10 years ago
Closed 10 years ago
#14208 closed bug (notabug)
wrap() function duplicates in IE
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.10.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
When i try to unwrap in string the <p> tag and then wrap the same contents with <div> tag it workes with Chrome, but not with IE.
Example:
<div id="div1"> One string <p>Two string </p> </div>
$('#div1').find("*").each(function(){
if($(this).prop("tagName").toLowerCase() == 'p') $(this).contents().unwrap().wrap('<div></div>');
});
Result: in Chrome <div id="div1"> One string <div>Two string </div> </div>
in IE <div id="div1"> <div>One string </div><div>Two string </div> </div>
I think this is enough for you to understand the problem, but please contact me if you need more information. Thank you for your attention.
Behavior of manipulation methods in general is not guaranteed for non-element nodes like the text node in your example. Note that both .wrap and .unwrap are clear to specify that they operate upon elements.