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:$('#selector').wrap('<a href="#">');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:
$('#selector').wrap('<a href="#"></a>');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.

No comments:
Post a Comment