开发者

How do I get the name or id of the element ?? Jquery

开发者 https://www.devze.com 2022-12-20 02:39 出处:网络
开发者_开发技巧How do I get the name or id of the element to jqueryIf you want to get the name/id from a selection

开发者_开发技巧How do I get the name or id of the element to jquery


If you want to get the name/id from a selection

$().attr('name') 

$().attr('id')

or for selecting element(s)

$('*[name="somename"]')

$('#someid')


Do you want to know the ID so can use it in the selector like $('#the-ID')? Either set it yourself if you can or look it up in the HTML source code.

0

精彩评论

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