Hellnar
Hellnar

Reputation: 64793

Jquery selector if has a title

Using jquery, I want to select input[type="text"] elements which has a title attribute(not a specific content, just the existance of the title).

How can I achieve that ?

Upvotes: 3

Views: 1034

Answers (3)

wsanville
wsanville

Reputation: 37516

You can specify multiple attributes, as in the following selector:

$('input[type="text"][title]')

Working example here: http://jsfiddle.net/VW64y/

Upvotes: 3

Keith.Abramo
Keith.Abramo

Reputation: 6955

$('input[type="text"][title]') 

Adding the attribute name in brackets without any ='s will search for all elements which have that attribute

Upvotes: 3

Dennis
Dennis

Reputation: 32598

An attribute selector without the equals clause will just test for existence:

$("input[type='text'][title]");

Upvotes: 3

Related Questions