Leahcim
Leahcim

Reputation: 41999

What does `a > b` mean?

I'm reading a tutorial about creating a shoutbox with jquery, php and ajax. In the jquery code, it creates a variable like this

var messageList = $(".content > ul");

There is a "content" class in the html, and it has an unordered list in it. But I don't understand the syntax .content > ul in the creation of the variable.

Can you explain?

HTML

 <div class="content">  
            <h1>Latest Messages</h1>  
            <div id="loading"><img src="css/images/loading.gif" alt="Loading..." /></div>  
            <ul>  
            <ul>  
        </div>  

Upvotes: 1

Views: 180

Answers (4)

marijnvdwerf
marijnvdwerf

Reputation: 921

It searches for a ul that's the direct child of .content, so if you'd change the html to

<div class="content">
   <div>
      <ul></ul>
   </div>
</div>

your selector wouldn't return anything. There's more info on all kinds of selectors on http://api.jquery.com/category/selectors/

Upvotes: 1

gion_13
gion_13

Reputation: 41533

css child selector

Upvotes: 1

rajasaur
rajasaur

Reputation: 5460

It indicates the shoutbox should be applied to a "ul" thats the immediate child of ".content". Without the ">" symbol, it applies to any ul thats a child of .content

Upvotes: 2

Paul Tomblin
Paul Tomblin

Reputation: 182802

It's a child selector.

Upvotes: 1

Related Questions