[jQuery] Fancybox from alt text

[jQuery] Fancybox from alt text


hi,
im trying to wrap a fancybox link around each image on a site, which
has an alt tag specified.
Right now i have this html markup:


<img src="1_s.jpg" alt="1_b.jpg" title="asdasd" />


And this javascript-code:
$(document).ready(function() {
$("img[alt]").each(function(){
$(this).wrap($('<a href="'+$(this).attr('alt')+'"
class="fancyBoxImage">'));
});
$(".fancyBoxImage").fancybox();
});
And it's working perfect in every browser, except IE7 and 8 (haven't
tested it in IE6 yet).
Does anybody has a explanation for it?