如何使用JQuery在HTML代碼中搜索?我想在HTML代碼中找到一個字符串,然後隱藏div。這不起作用:在HTML代碼中搜索?
<div class="example">
test
<img src="example.jpg"></div>
$(document).ready(function(){
$(".example:contains('example.jpg')").hide();
});
但是,當我告訴它來搜索「測試」,而不是「example.jpg」,它的工作?
:包含搜索文本內容,而不是在孩子的屬性內容元素。 – 2013-05-01 20:35:03
然後有HTML選擇器嗎?我試過.attr()並且不起作用。 – user2338015 2013-05-01 20:35:51
'$('[src =「example.jpg」]')'會做到這一點 – Blazemonger 2013-05-01 20:36:14