0

I'm still learning how to use Sizzle selector. So far I know this:

Sizzle('#blah') - searches the entire document for element(s) with id 'blah'.

Sizzle('.blah') - searches the entire document for element(s) with css class 'blah'.

Then today I found this:

Sizzle('> div') - searches entire document for elements of 'div' tags. (I could be wrong but that's what it is doing for me)

Which makes me ponder, what other syntax are there to search for stuff using Sizzle??

Gary
  • 1,001
  • 8
  • 17

3 Answers3

2

The > is called child selector and is used to find direct/immediate children of parent elements.

Example:

<ul id="ul">
  <li>Child</li>
  <li>Child</li>
  <li>Child</li>
  <li>
      <ul>
         <li>Child Again</li>
         <li>Child Again</li>
         <li>Child Again</li>
      </ul>
  </li>
</ul>

Sizzle:

Sizzle('ul#ul > li')

In the above example, the child selector will only select direct children that is ones with text Child not Child Again

Sarfraz
  • 377,238
  • 77
  • 533
  • 578
  • 1
    To elaborate - the syntax that sizzle uses is a superset of [CSS selector](http://www.w3.org/TR/css3-selectors/) syntax. – Matt Ball Aug 27 '10 at 15:08
1

pretty much any selector you can do with css3 you can do with sizzle.

Patricia
  • 7,752
  • 4
  • 37
  • 70
1

Here's the official reference on which selectors Sizzle supports: http://wiki.github.com/jeresig/sizzle/. But, as has already been said, it's basically the same syntax as CSS3 selectors.


And here's the link the OP was apparently asking for: http://www.w3.org/TR/css3-selectors/

Matt Ball
  • 354,903
  • 100
  • 647
  • 710