如何在按下按钮时检查文本字段是否输入了某个文本?
答案 0 :(得分:0)
这段代码将在字符串'searchMe'中搜索字符串'lookFor',并将结果(boolean)存储在'result'中
let searchMe = 'can you find me in here?'; //string to search
let lookFor = new RegExp("find me"); //reg exp pattern to look for
let result = lookFor.test(searchMe); //result of the search (true/false)
尝试将此逻辑应用于按钮单击处理程序。祝你好运!