I used wrap operation to insert a span into a UL container to perform a toggle expand/collapse of a tree menu. So the span should wrap over the ul container as stated in jQuery documentation. However, in IE it couldn’t seems to find this particular new span that was inserted through the wrap operation. Since this is a JavaScript DHTML operation, obviously it won’t show during view source. I tried to debug by firebug lite to find out .the issue and found jQuery warp doesn’t support IE. I used the code as follows
$(‘ul.tree.dhtml ul’).prev().wrap(“<span class=’grower OPEN’>”)
which is working fine in other browser but IE doesn’t do.
Solution:
IE requires end tag to wrap. So I used the following code to fix the issue but this will also create same problem in other browser.
$(‘ul.tree.dhtml ul’).prev().wrap(“<span class=’grower OPEN’> </span>”)
Finally I had to check the browser identity.
var browpattern = /Internet/;
if(browpattern.test(navigator.appName)) { // IE: Microsoft Internet Explorer
$(‘ul.tree.dhtml ul’).prev().wrap(“<span class=’grower OPEN’> </span>”);
} else {
$(‘ul.tree.dhtml ul’).prev().wrap(“<span class=’grower OPEN’>”);
}
There are several ways to get browser identity and you can use any of them.