Use of jQuery usually starts with you selecting one or more elements in a web page.
Selectors is the start of how you will identify which elements you want jQuery to work on.
To start with jQuery, you will typically use the $ (dollar sign) symbol as a shortcut to call jQuery, or jQuery name itself. The selector will be in parenthesis, and is a string of text. Generally it will look something like the following:
If this looks familar, then that is good. This is actually a function that gets called. And you get to pass a parameter to identify the web elements you want to select.
What can you select?
jQuery allows you to select elements using CSS3 selectors, even if they are not supported in the browser that your end user is currently using. This includes pseudo selctors like :first, :odd and more.
Since I use CSS selectors, I will use the hash mark to identify elements with an ID, and a period to identify classes, such as:
I can also select a more specific element by using combinations. This would be something like:
$('#nav a.selected') $('#content p:first') $('div + p')
In the next section we will look at how to work with those elements so that you can do something besides select them.