Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery select textarea based on value

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?

like image 821
Mark Steudel Avatar asked May 29 '26 23:05

Mark Steudel


1 Answers

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

.filter() API docs

like image 94
Matt Ball Avatar answered May 31 '26 12:05

Matt Ball



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!