我试试这个:
form['comment'] = '<blockquote>test</blockquote><a href="#">test</a> <Your reply here>';
if($(form['comment']).search('<Your reply here>'))
alert(1)
else
alert(0)
但是有这个错误:
TypeError:$(form.comment).search不是函数
我解决了这个问题:
if(form['comment'].value.search('<Вашият отговор тук>') != -1)
alert(1)
else
alert(0)
答案 0 :(得分:3)
你想要的是$(form['comment']).text().search()
所以:
form = [];
form['comment'] = '<blockquote>test</blockquote><a href="#">test</a> <Your reply here>';
if(form['comment'].search('<Your reply here>') != -1)
alert(1)
else
alert(0)
答案 1 :(得分:0)
要找出匹配字符串的其他内容,您不需要jQuery!。
var comment = "<blockquote>test</blockquote><a href="#">test</a> <Your reply here>",
search = "<Your reply here>";
comment.indexOf( search ) != -1; // indexOf returns -1 when search does not match
/<Your reply here>/.test( comment ); // returns true when search is in comment.