jQuery 如何选择具有指定类和 rel 的锚标记?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6840247/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 21:27:06  来源:igfitidea点击:

How to select anchor tag with specified class and rel?

jqueryjquery-selectorsanchorrel

提问by daGrevis

I have an anchor tag like this, and I need to select it!

我有一个这样的锚标签,我需要选择它!

<a href="#" class="foo bar" rel="123">...</a>

Is it possible with jQuery to write a selector that selects an anchor that has class like foo barand rel like 123?

是否可以使用 jQuery 编写一个选择器来选择具有类 likefoo bar和 rel like的锚点123

回答by Qtax

You can use something like:

您可以使用以下内容:

$('a.foo.bar[rel="123"]')