Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 948403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:14:25+00:00 2026-05-15T23:14:25+00:00

there’s a list of items on a page, some blank, with one example being:

  • 0

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&nbsp;&nbsp;&nbsp; <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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:14:26+00:00Added an answer on May 15, 2026 at 11:14 pm

    Updated answer: Based on clarification in comment, try this instead:

    $('div.item:has(a.article[href=""])').remove();​
    

    Or this should also work:

    $('div.item:has(a.article:not([href]))').remove();​
    

    Or if you have issues with either of those, try this:

    $('div.item a.article').filter(function() {
        return $.trim(this.innerHTML) == '';
    }).closest('div.item').remove();​​​​​​​
    

    Original answer:

    Using jQuery:

    $('div.item:has(a.article)').remove();
    

    This will select <div> elements with the class item that has a descendent <a> element with the class article, and remove them.

    Of course, you could use .hide() instead if you like:

    $('div.item:has(a.article)').hide();
    
    • http://api.jquery.com/has-selector/
    • http://api.jquery.com/remove/
    • http://api.jquery.com/hide/

    If you really meant that you only want to remove the actual parent of the a.article, then you would do this:

    $('div.item :has( > a.article)').remove();
    

    This will remove the parent of a.article instead of the one with the .item class. Wasn’t sure which you meant.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is a class that's a fully fledged UIViewController and when that page loads
There's many examples of testing RoR model validations. Even keeping the test being DRY
There are several shading languages available today like GLSL, HLSL, CG, which one to
There's a few previous questions on StackOverflow questioning how one goes about accessing local
There is a div (form) which opens on the click of a button. There
There is no doubt that MonoTouch is one of the great cross-compiler(s). Similarly, SenchaTouch
There are two field in my form. 1) Html select field item ( From
There are lots of posts on here about moving a folder out of one
There are a few ways to get class-like behavior in javascript, the most common
There is a method in the Messages class called questionWhatisYourName() this method is called

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.