jquery选择器:按名称定位元素 [英] jquery selector: anchor elements by name
本文介绍了jquery选择器:按名称定位元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是jQuery的新手,所以这可能很简单,但... ...
如果我有这个HTML:
< a name =foo> Foo< / a>
如何通过名称选择锚元素 foo
?它没有 id
属性。
解决方案
它是这样的:
$('a [name = foo]')
它被称为属性equals选择器。
I'm new to jQuery so this is probably simple, but...
If I have this HTML:
<a name="foo">Foo</a>
how can I select the anchor element by its name foo
? It doesn't have an id
property.
解决方案
You can do it like this:
$('a[name=foo]')
It's called a attribute equals selector.
这篇关于jquery选择器:按名称定位元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文