abiieez
abiieez

Reputation: 3189

jQuery selector for elements with name attribute

How can I select elements which contains "name" attribute ?

Example of the elements :

<select id="itemPK.country.id_id" name="itemPK.country.id"><option value="7">India</option><option value="8">Malaysia</option></select>

<input id="point_id" name="point" type="number" value="">

Upvotes: 1

Views: 82

Answers (3)

Brandon
Brandon

Reputation: 39182

Use the attribute selector

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

Upvotes: 1

mariano
mariano

Reputation: 1367

The attribute selectors are what you need:

$('input[name="point"]')...
$('[name="something"]') //In case it's not specifically an <input> element

Good luck

Edit: I see, you may have asked for elements which contain a certain attribute, not those that contain X value in the name attribute. The answer provided by PSR is the way to go. This is the documentation for the "Has attribute" selector.

Upvotes: 2

PSR
PSR

Reputation: 40318

$('[name]')

try this you can get all elements having name

Upvotes: 3

Related Questions