jquery val() contains()

Hussein picture Hussein · Feb 8, 2011 · Viewed 57.4k times · Source

I want to know if the textarea value contains a certain word. This is not working for me.

var value = $('#embedModal textarea').val();
if($(value).contains('iframe')){...

Answer

Nikita Rybak picture Nikita Rybak · Feb 8, 2011

Try javascript

if (value.indexOf('iframe') >= 0) {

JQuery contains is for DOM elements, not strings.