I have the following code:
$('#main-nav a').mouseover(function() {
var name = $(this).attr("rel");
$("#subnav ul." + name).show();
})
Basically the code just gets the value of the rel attribute of a link when it is hovered over and then makes any ul with a class of the same value appear.
This code works fine in any other browser apart from IE6 and 7 which gives me the following errors:
- exception thrown and not caught (in my jquery 1.4.4 file)
- object doesn’t support this property or method (in my jquery script that iv wrote)
It is something to do with the fact that iv used a variable in my selector, if i dont use a variable I don’t get these errors.
The thing is though I need to put the variable in there in order for it to work, does anyone know of a better way to do this that won’t cause these errors?
Thanks
As far as I can tell,
'#main-nav a'returns a collection of<a>objects. Have you tried iterating the result witheach?