按标题 jQuery 获取元素
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3080339/
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
Get element by title jQuery
提问by van
I have searched but cannot find the jQuery selector that gets an element by a title. So I would be trying to get a handle on the dropdown with title =='cars'
我已经搜索过但找不到通过标题获取元素的 jQuery 选择器。所以我会尝试使用 title =='cars' 来处理下拉列表
Eg:
例如:
<select title='cars'>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
Thanks alot,
非常感谢,
回答by Nick Craver
Use the attribute-equals selector, like this:
使用属性等于选择器,如下所示:
$("select[title='cars']")
There are other attribute selectorsavailable as well if the need arises :)
如果需要,还有其他属性选择器可用:)