I am trying to wrap an anchor-tag around a block of code using jQuery (v1.2.6) by doing the follwing:
var link = $('<a>').attr('href','http://www.foo.bar');
$('#block').wrap(link);
This works perfectly fine in all browsers but (you guessed it) the Internet Explorer (all versions I can use to test it). I do know from other cases that the IE is hella picky when you insert code via JavaScript, but in this case I just don't know what could be wrong with this simple anchor element? Anyone got an idea? Btw: I already tried generating the anchor via $('<a></a>')
as suggested on several other posts unfortunately, makes no difference for me.
Thanks a whole lot!
Updating my jQuery to 1.3+ did the trick.
Apparently
var a = $('<a>');
in jQuery 1.2.6 and earlier will create a chunk of code that IE considers invalid and therefore will refuse to insert it into the DOM tree.