使用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 關注
- 1152 瀏覽
添加回答
舉報
0/150
提交
取消