there’s a list of items on a page, some blank, with one example being:
<div class="item itemask">
<div class="tophead">
<div class="itemnumber">30</div>
<a class="article" href=""></a>
</div>
<div class="bottomhead"> points by <a class="userlink" rel=""></a> ago <a href="/item?id=">discuss</a>
</div>
Hence, what jQuery or JavaScript could be used to find an instance of: <a class="article" href=""> in any instance of a div class=item on the page, and then delete or hide that individual parent div of class=item which contains that piece of code?
Updated answer: Based on clarification in comment, try this instead:
Or this should also work:
Or if you have issues with either of those, try this:
Original answer:
Using jQuery:
This will select
<div>elements with the classitemthat has a descendent<a>element with the classarticle, and remove them.Of course, you could use
.hide()instead if you like:If you really meant that you only want to remove the actual
parentof thea.article, then you would do this:This will remove the parent of
a.articleinstead of the one with the.itemclass. Wasn’t sure which you meant.