Jquery select textarea based on value

I am trying to select textareas based on the value in them, I tried to do this:

alert( $('textarea[value="Type"]').length );

But I get zero.

Here is my text box:

<textarea id="Title" name="title" rows="5" cols="29" class="textentry_verdana12pxItalic">Type</textarea>

Can I do it?

+3
source share
4 answers

valuenot an attribute of this text field. This HTML textarea attributes: id, name, rows, colsand class. Try instead:

$('textarea').filter(function ()
{
    return $(this).val() === 'Type';
}).length

.filter() API Docs

+5
source

Use the pseudo-selector "contains":

jQuery('textarea:contains(Type)')
+1
source

Try   alert ($ ('textarea: ( "" )'). length);

0

(contains-selector):

alert($("textarea:contains('Type')").length);
0

All Articles