Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I select the 'title' attribute in an input tag in jquery?

Just like we have selectors like ("#id_name"),(".class_name") (":input_type")..etc in jquery, how can I select the title attribute from an input tag?

Example: < input type="abc" id="xyz" title="information" >

I need a selector to select title value.

like image 762
Rahul_2289 Avatar asked Jul 27 '11 12:07

Rahul_2289


2 Answers

$('input[title="information"]');
like image 66
Alex Ackerman Avatar answered Sep 19 '22 13:09

Alex Ackerman


$('input').attr('title');

@Alex is partially correct, you can have numbers but the id just cannot start with a number.

in your case you would selected the input like this.

$('#xyz').attr('title');
like image 38
locrizak Avatar answered Sep 16 '22 13:09

locrizak