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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:56:35+00:00 2026-06-07T11:56:35+00:00

I have the following setup: <div id=whatever> <!– Here some dynamic divs will be

  • 0

I have the following setup:

      <div id="whatever">
           <!-- Here some dynamic divs will be loaded -->
      </div>

I need to know when the “whateverdiv” has nothing inside. The catch is that when I say nothing I mean if user sees nothing. So if inside the div something like

      <div style="display: none">LOOOONG TEXT</div>

is loaded I consider it empty.

If is full of blank spaces is also empty, etc… if user doesn’t see anything in it is empty.

Since there are too many cases to cover (content with height 0, content with display none, blank spaces, tabs, hidden inputs etc… almost anything may be loaded there depending on situations) I tried to use the height attribute to see if has content (the div expands depending on content). This idea worked ok but now I have another problem: I must add display: none on it sometimes. When I do that the height is always load as 0. I can’t use visibility because div has 10px padding that I don’t want to see when is not shown. So I’m back to square one… finding some sort of way to see if a div is empty in all that cases.

Any idea how should I do that?

  • 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-07T11:56:37+00:00Added an answer on June 7, 2026 at 11:56 am

    This one should work.
    http://jsfiddle.net/fedmich/SmRnT/

    I’m cleaning the html comments via Regex

     $(function() {
        var w = $('#whatever').clone();
        w.find(':hidden').remove();
    
        var html = w.html();
        html = html.replace(/<!--.*-->/g,'')
        html = $.trim(html);
    
        alert( html );
    });​
    

    To summarize

     clone the object
     remove hidden elements
     remove html comments
     $.trim(  )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following setup, and I need to know how to persist state.
Ok... I have the following setup: A div with n divs as children (n
I have the following setup: <div id=whatever onclick=dostuff()>Super Mega Giga Button or Whatever</div> <!--
I have the following setup: <div>Element with CSS3 animated height change</div> <div><a href=#>Link</a></div> I
I have this following setup, a textarea named with some data in it that
I have the following setup on 2 div tags: <div id='div1' style='position: absolute; z-index:
I have the following title div setup, but when only the leftmost div has
I have the following ul setup: <div id=sidebar> <ul id=themenu class=sf-menu sf-vertical> <li> <a
I have a website with the following setup: <div id=container> <div id=header></div> <div id=content></div>
I have following setup: .calender-month{ float:left; } .buttondiv{ float:left; } <div class=buttondiv><button id=backbtn>back</button> <div

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.