JavaScript search() fails to find “()”

后端 未结 2 1289
余生分开走
余生分开走 2021-01-18 10:23

This might seem trivial, but I\'m new to JS. I have this piece of code:

alert(elementAction);    
var argumentsBegin = elementAction.search(\"(\");
var argum         


        
2条回答
  •  爱一瞬间的悲伤
    2021-01-18 11:02

    elementAction.search("\\(");
    

    search is regular expression, ( is keyword in regular expression. you have to escape ( to \(, \( in string is "\\("

提交回复
热议问题