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 6886793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:48:14+00:00 2026-05-27T05:48:14+00:00

I am trying to remove an element in jquery if the contents are equal

  • 0

I am trying to remove an element in jquery if the contents are equal to a variable set in jquery. In this example I am trying to remove .sub3 as the contents are equal to the variable set.

<div class="sub1">
    <a href="/large.jpg" class="group1 cboxElement">
    <img border="0" alt="" src="/thumb.jpg">
    </a>
</div>

<div class="sub2">
    <a href="/029-large.jpg" class="group1 cboxElement">
    <img border="0" alt="" src="/029-thumb.jpg">
    </a>
</div>

<div class="sub3">
    <a href="" class="group1 cboxElement"></a>
</div>

The Jquery I have come up with just removes the whole element regardless

var nopic = <a class="group1 cboxElement" href=""></a>;

if($.trim($(".sub1").text()) == nopic) {
$(".sub1").remove();
}

if($.trim($(".sub2").text()) == nopic) {
$(".sub2").remove();
}

if($.trim($(".sub3").text()) == nopic) {
$(".sub3").remove();
}

Thanks for any pointers!

  • 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-27T05:48:15+00:00Added an answer on May 27, 2026 at 5:48 am

    One line, simple case that works on all empty links:

    $('div[class^="sub"] a.group1.cboxElement[href=""]').parent('div').remove()

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

Sidebar

Related Questions

i got this javascript, trying to remove a class on a parent element: $(this).parents(.box).removeClass(expanded);
I'm trying use jquery to remove a class from an element (not knowing ahead
Trying to remove the last child of an element only if the class =
I'm trying to remove this element on success function, but it's not doing it!!
I am trying to remove the elements and contents before a link inside a
I have an element inside a div that is draggable jquery ui. And I
I am trying to remove an element from a Javascript associtive array using the
I'm trying to implement a jQuery fallback for the details element. If you've never
I am trying to change the background image of an element through jquery like
I'm trying to recreate an effect in jQuery, where an element ( <li> <img>

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.