To begin, you select elements with jQuery with the $ symbol:
// to select all paragraph tags $("p") // to select a class called header $(".header") // to select an element with ID intro $("#intro") // to select all a tags inside of li's $("li a")
How to select a specific number n in a list. Given this:
We can see that if we select all li‘s and ask for the first it will give us the first li in each list, whether the list is ordered or not. If we want to select just the first li in the unordered list we have to specify that.
Then to apply a style to the selected object you use the following jQuery method:
Here is a quick example of the .css method:
We can also pass in an object for the styles:
?is this the correct syntax for this? Camel case instead of background-color etc?
!Yes! In jQuery you use camel case instead of actual CSS selectors!
Here are some more quick examples: