I want to use `$('body:contains("")')` for searching part of a html code.
For example:
var thing = $('body:contains("Web")').text()
if(thing) {
alert(thing);
}
else{
alert("not found")
}
This code always alerts "not found".
Is it possible to search a part of a html code and alert if found?
Thank you... Beware that you may see "Web", when inspecting with your browser, but the actual code may contain whitespace or not even have closing tags! Even if the source is "Web" now, stuff like that can break very easily on pages that you do not control.
以上就是Javascript: $('body:contains("")') with html的详细内容,更多请关注web前端其它相关文章!