How can I get name of element with jQuery?

Poonam Bhatt picture Poonam Bhatt · Jan 13, 2012 · Viewed 291.6k times · Source

How can I get name property of HTML element with jQuery?

Answer

Nicola Peluchetti picture Nicola Peluchetti · Jan 13, 2012

You should use attr('name') like this

 $('#yourid').attr('name')

you should use an id selector, if you use a class selector you encounter problems because a collection is returned