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(\'i
You can do this as well:
if($('#embedModal textarea:contains("iframe")').length > 0){
//TODO: do stuff
}
Try doing it like this:
$('#embedModal textarea:contains("iframe")').each(function() {
//Do something
});
edit
Example
Try following code.....
code:
<textarea rows="4" cols="9">Something iframe</textarea>
<textarea rows="4" cols="9">Something</textarea>
var obj=$("textarea:contains('iframe')");
if(obj){
obj.css("background-color", "red");
}
Try javascript
if (value.indexOf('iframe') >= 0) {
JQuery contains is for DOM elements, not strings.
this works:
$.contains( document.documentElement, document.body ); // true
var babyEl = $('div#id');
var daddyEl = $('div#ID');
if($.contains(babyEl, daddyEl)) {
//do fun stuff
}