views:

95

answers:

1

Hi,

Is it possible to refer to an attribute of an element conditionally with Jquery?

What I'm after is something like:

$(".mylink":rel["2"]).show();

... which would "show the specific instance of .mylink element on the page that has rel="2" HTML attribute on it. There would be multiple instances of .mylink on the page, each with its own "rel" value.

Thank you.

+2  A: 

Like this:

$('.mylink[rel=2]').show();

If the "rel" value is a variable or something, you can do:

$('.mylink[rel=' + relValue + ']').show();
Pointy
Thanks, it works, let's the jquery execute fine but I it doesn't want to show.... It's just an integer, like in your first example.
Tom
Actually, looks like the show problem is caused by something else. Your code works, thanks.
Tom