jQuery .search() to any string

后端 未结 3 1387
生来不讨喜
生来不讨喜 2020-12-05 12:28

I saw this code snippet:

$(\"ul li\").text().search(new RegExp(\"sometext\", \"i\"));

and wanted to know if this can be extended to any str

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-05 12:53

    if (str.toLowerCase().indexOf("yes") >= 0)
    

    Or,

    if (/yes/i.test(str))
    

提交回复
热议问题