开发者

Jquery: Conditional reference to attribute?

开发者 https://www.devze.com 2022-12-21 10:58 出处:网络
Is it possible to refer to an attribute of an element conditionally with Jquery? What I\'m after is something开发者_运维问答 like:

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

精彩评论

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