Hello jQuery Lesson 3
Using elements without declaring css beforehand
using id selectors for jQuery to grab
You can select children (immediate descendants), descendants (all grandchildren, etc , as well), parents, and grandparents
- Item 1 - li:first-child
- Item 2
- Item 3
- A Hello from the nest - li li: first-child
- Been here a bit
- C
But usually, you will want to find all the li items, so you will use .find instead of .children,
so it will search recursively through the tree:
- Item 1 - li:first-child
- Item 2
- Item 3
- A Hello from the nest - li li: first-child
- Been here a bit
- C
jQuery also has its own custom selectors and DOM Traversal Methods that aren't provided by css, like
- .first()
- eq(x)
- next()
- prev()
- .text('some_text')
Here we use some:
- Item 1 - li:first-child
- Item 2
- Item 3
- Item 4
- But you really want to use css selectors in the jQuery if you can