Your div.bc-wrapper isn't empty. It has a text node in it because of the
whitespace.

Open Firebug on any page that uses jQuery and switch it to the multiline
console (orange up arrow at the bottom right). Then paste this code in, hit
Ctrl+Enter, and observe the results:

    $a = $('<div><div class="wrapper"></div></div>' );
    $b = $('<div><div class="wrapper"> </div></div>' );
    console.log( $a.find('div.wrapper:empty') );
    console.log( $b.find('div.wrapper:empty') );

-Mike


> From: Vinoj
> Sent: Tuesday, September 30, 2008 2:10 PM
> 
> I've got the following as my jquery code:
> <script type="text/javascript">
>       $(document).ready(function() {
>       $(".bc-wrapper:empty").(this).parent().addClass("none");
>       });
> 
> </script>
> 
> And the html is:
> 
> <div class="bottom-content">
>    <div class="bc-wrapper">
> 
>      </div>
> </div>
> 
> The css is as follows:
> .bottom-content {
>       display: block;
>       width: 215px;
>       border: 1px solid #ccc;
>       float: left;
>       margin-right: 20px;
>       }
> .bc-wrapper {
>       padding: 5px;
>       }
> .none {
>       visibility: hidden;
>       border: none;
>       }
> 
> ----------------------------------
> Basically in this example, I'd like the bottom-content class 
> to be hidden if the bc-wrapper class has no content. 
> Unfortunately, I believe I've written my code wrong (in all 
> the different variations I've tried) for jQuery because 
> nothing is happening. Even when I check with Firebug, there's 
> no class attached anywhere.
> 
> Any thoughts?
> 

Reply via email to