Reputation: 1682
I'm trying to select textareas based on the value in them, I tried doing this:
alert( $('textarea[value="Type"]').length );
But I get zero.
Here's my textarea:
<textarea id="Title" name="title" rows="5" cols="29" class="textentry_verdana12pxItalic">Type</textarea>
Can I do this?
Upvotes: 3
Views: 2341
Reputation: 359826
value
is not an attribute of that textarea. That textarea's HTML attributes are id
, name
, rows
, cols
, and class
. Try this instead:
$('textarea').filter(function ()
{
return $(this).val() === 'Type';
}).length
Upvotes: 5
Reputation: 14967
try this (contains-selector):
alert($("textarea:contains('Type')").length);
Upvotes: 0
Reputation: 19560
Use the "contains" pseudo selector:
jQuery('textarea:contains(Type)')
Upvotes: 1