jQuery, wrap(), and IE
Posted on 2009-12-29 (Updated on 2019-01-24)
I decided to create a collapsible/expandable navigation script as one of my first forays into jQuery, and ran into an interesting issue with the way I was using the wrap() function, and the way Internet Explorer interpreted it.
I was adding some anchor tags via wrap(), like so:
This worked fine in every browser I tested in, as long as it wasn't made in Redmond. The code ran fine, without any errors, but wrap() never added the anchors. This really stumped me for a while, since it not only broke in IE6, but 7 & 8 as well.
A quick change to the code, however, had everything working everywhere:
Who knew IE was a stickler for properly formatted code? I'm not sure why this happens, but hopefully my discovery will save you some time in the future.
jezra – http://www.jezra.net