jquery - How can I target a div based on the image src container within? -
i new jquery, , wondering if it's possible select div based on image's source contained within? , remove entire div if finds instance?
so in example how through div's class of thumbnail image
src="http://demo.com/wp-content/themes/thestyle/timthumb.php?src=&h=180&w=222&zc=1&q=90"
and delete divs?
<div class="thumbnail"> <a href="http://www.demo.com"> <img src="http://demo.com/wp-content/themes/thestyle/timthumb.php?src=&h=180&w=222&zc=1&q=90"> </a> <div class="date"> january 1st </div> </div>
use :contains
selector.
$('div.thumbnail:contains(img[src="http://example.com/foo/bar"])').remove();
or select <img>
, use .closest()
:
$('img[src="http://example.com/foo/bar"]').closest('div.thumbnail').remove();
learn dig through jquery api docs. they'll answer 99% of questions.
Comments
Post a Comment