Treehouse: Grow your CSS skills. Land your dream job.

Hiding an Empty Div with jQuery

  • # May 24, 2012 at 11:40 am

    Hi all – I have been having such a hard time trying to hide a div that is empty with jQuery. Any Ideas?

    $(document).ready(function() {
    if($(".itemBubble").html() == ""){

    # May 24, 2012 at 11:53 am

    well the problem is that you have multiple divs with class .itemBubble i guess.
    you have to use something like each. dont know if theres a better way, im no expert.. but maybe it helps:

    # May 24, 2012 at 12:16 pm

    Thanks! I figured out that it wasn’t working because I had some weird spacing going on.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.