Link to home
Start Free TrialLog in
Avatar of badwolfff
badwolfffFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How do I use jQuery to hide an empty div?

I tried it on jsfiddle: https://jsfiddle.net/lupocatttivo/tmLw9e56/
but it doesn't seem to work :(

any ideas?

thanks
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

What you have would only work if the div was truly empty, no carriage returns, no tabs, no spaces.

https://jsfiddle.net/tmLw9e56/1/
Avatar of badwolfff

ASKER

Thanks. But I need the jquery to work on my html. It is auto-generated so I can't intervene on its formatting.

any ideas?
ASKER CERTIFIED SOLUTION
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
it's because it has (space) between the <div> and</div> tag, once removed all the space it worked :)

existing DIV
<div class="newprice" style="padding-bottom: 10px; width:200px; height:200px; background-color:#ff0080">
                                                          </div>
Empty DIV
<div class="newprice" style="padding-bottom: 10px; width:200px; height:200px; background-color:#ff0080"></div>