why javascript contains property is not working in chrome browser?

前端 未结 6 1313
孤城傲影
孤城傲影 2021-02-01 15:39

Why javascript contains property is not working in chrome browser? I have tried that Contains Property in javascript.It is working fine in Mozila Firefox Browser. But It is

6条回答
  •  囚心锁ツ
    2021-02-01 16:19

    I think you should be using indexOf

    var ClearFilterValue = 'family Schools';
    if(ClearFilterValue.indexOf("family") !== -1) {
          alert('Success');
    }
    

    Also not sure if you should be making a polyfill as pretty much no browser seems to support it anyways https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/contains

    None of IE's support it, Chrome apparently starting at 30, FF starting at 19, and i doubt mobile browsers support it either

提交回复
热议问题