MrNase wrote:
I am currently at war with the contains function. :-(


Here's my snippet which doesn't work.

                $('#myTextarea').bind("keyup", function(){

                                if 
($('#myTextarea').attr('val').contains('hello'))     {

                                        log.empty().html('test');
                                }


I want to bind a function to a textarea - On every 'keyup' event,
jQuery should search the text inside the textarea for the word
'hello'. If that word is found it should print out a debug message to
a layer.


I already tried several versions including this one:

$('#myTextarea').bind("keyup", function(){
                if ( $("#myTextarea[value:contains('hello')]"))
log.empty().html('test');
});


How can I use 'contains()' together with a textarea?


Thanks for reading and many thanks for helping! :)

Do not use contains() at all here. $('#myTextarea').attr('val') returns a string, thus use string methods:

$('#myTextarea').attr('val').indexOf('hello') != -1


--Klaus

Reply via email to