开发者

Jquery: Conditional reference to attribute?

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.


Like this:

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

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

$('.mylink[rel=' + relValue + ']').show();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜