使用jQuery查找文本字符串?假设一个网页有一个字符串,比如我想要找到的“我是一个简单的字符串”。我将如何使用JQuery来解决这个问题呢?
3 回答
慕田峪9158850
TA贡献1794条经验 获得超8个赞
$('*', 'body')
.andSelf()
.contents()
.filter(function(){
return this.nodeType === 3;
})
.filter(function(){
// Only match when contains 'simple string' anywhere in the text
return this.nodeValue.indexOf('simple string') != -1;
})
.each(function(){
// Do something with this.nodeValue
});- 3 回答
- 0 关注
- 1179 浏览
添加回答
举报
0/150
提交
取消
