Mandoleen
Mandoleen

Reputation: 2661

JQuery selector logical "and"

How can I access elements that have name X and type hidden?

Upvotes: 11

Views: 21483

Answers (3)

Amir Raminfar
Amir Raminfar

Reputation: 34179

You should try this if you want type=hidden

$('input[name="X"][type="hidden"]')

If you want an element that is hidden via css then you should try

$('[name="X"]:hidden')

Upvotes: 18

StuperUser
StuperUser

Reputation: 10850

$('[type="hidden"][name="X"]');

See: http://api.jquery.com/multiple-attribute-selector/

Upvotes: 5

Surreal Dreams
Surreal Dreams

Reputation: 26380

$('[name="X"]:hidden').dosomething();

This will select an element with a name="X" attribute which is hidden. You can learn lots more about jQuery selectors - there's plenty of useful help there.

Upvotes: 0

Related Questions