views:

60

answers:

2

How do I get the name or id of the element to jquery

+1  A: 

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.

Felix Kling
Ok. I did. I wanted to get the name of the html element
TeknoSeyfo
Don't forget quotes around "#the-ID".
Wayne Koorts
+2  A: 

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

$().attr('name') 

$().attr('id')

or for selecting element(s)

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

$('#someid')
Simon