Elangovan Elangovan - 1 month ago 7
Javascript Question

why javascript contains property is not working in chrome browser?

why javascript contains property is not working in chrome browser?
I have tried that Contains Property in javascript.It is working fine in Mozila Firebox.But It is not working in Chrome browser.How to fix this?

Link: http://www.codingslover.com/2014/11/why-javascript-contains-property-is-not.html

var ClearFilterValue='family Schools';
if(ClearFilterValue.contains("family")== true) {
alert('Success');
}

Answer

indexof returns the position of the string. If not found, it will return -1:

var ClearFilterValue = 'family Schools';
alert(ClearFilterValue.indexOf("family") != -1);
Comments