jquery selector: anchor elements by name

寵の児 提交于 2019-12-23 07:57:34

问题


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.


回答1:


You can do it like this:

$('a[name=foo]')

It's called a attribute equals selector.



来源:https://stackoverflow.com/questions/8948758/jquery-selector-anchor-elements-by-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!