MrNase wrote:
$('#myTextarea').attr('val').indexOf('hello') != -1--Klaus$('#myTextarea').val().indexOf('hello') != -1 works. Thanks! :) Now, when I extend my code it doesn't work anymore. if ($('#myTextarea').val().indexOf('hello') != -1) { log.empty().html('test'); } else if ($('#myTextarea').val().indexOf('moo') != -1) { log.empty().html('test2'); } typing in 'moo' works, the log layer get's filled with 'test2'. typing in 'moo hello' also works, the log layer get's filled with 'test'. typing in 'moo hello moo' should produce 'test2' but it just does nothing. :(
That is correct. indexOf works by exact matching, thus "moo hello moo" may not match and nothing gets logged, both the if and the else condition are false.
You may have to use regular expressions for a bit more flexibility. --Klaus

