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

  • Home
  • SEARCH
  • 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 8847105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:07:58+00:00 2026-06-14T12:07:58+00:00

I have some generated output like this: <figure> <a href=location.php><img src=></a> </figure> and when

  • 0

I have some generated output like this:

<figure>
    <a href="location.php"><img src=""></a>
</figure>

and when I apply this JS:

$(funciton() {
    $('img').each(function(){
        if($(this).attr('src') == null || $(this).attr('src') == '')
            { 
                $(this).parent().remove();
            }
});

It removes the img tag, and it’s parent a tag but leaves this output on the page:

<figure>
"&#8203"            ​
</figure>

How can I remove the paren’t ‘s parent tag or just trim it so there is no blank entity present? When there is anything in the figure tag it has a 1px height and margin from css. I can change css, but want to figure this out, help is much appreciated!

  • 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-06-14T12:07:58+00:00Added an answer on June 14, 2026 at 12:07 pm

    If you want to make sure that the parent <figure> tag is empty if the image tag has no .src, you can do this:

    $(function() {
        $('img').each(function() {
            if(!this.src) { 
                $(this).closest("figure").empty();
            }
         }
    });
    

    .empty() removes all childnodes and any text in the element.

    Note, I also simplified your comparison on .src. First off, there’s no need to use jQuery here and second off, a single test can check for any empty value.

    If you really want the <figure> tag to take up no space on the page, you might also just do a .hide() on it.

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

Sidebar

Related Questions

I seem to be confused about PHP output buffering. I have code like this:
I have been given some generated code which looks like so: <form id=form1 method=post
I have a form with some generated input fields like theese: <input value=March name=month[March]
I would like to have something like this be generated from hbm2ddl: ______________ ______________
Problem I have some pages that need dynamic data from website to generate output
I have an application that takes some input and generates configuration files as output.
I have some PHP code that generates a calendar and then outputs html to
I have some auto-generated HTML code. When I add a float:left; on the shared
I have some data generated in MATLAB that I want to process using Perl.
Fiddle: http://jsfiddle.net/MhWm5/16/ I have some dynamically generated table rows/values with dynamic IDs <td class=control-group>

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.