JQuery Selectors:selectors allows us to find a html elements so, we can manipulate it's attributes programmatically.
Id Selector : Id selectors are used to find an element for it's Id for example, HTML button has Id 'button1'. We can find this button with #Id inside of $ function, like

- If we have multiple elements with same Id then JQuery will select first element with matched Id.
- If there is no element with given Id then JQuery will not throw an error while it will be an empty colletion, to be sure that there is an element with given Id we can check it's length like if($('#button1').length>0 ) then perform operation on button.
- $('#button1') is not similar to document.getElementById('#button1') in case of Jquery we will get JQuery object and we are able to call methods provided by JQuery like .css() etc. while Document.getElementById returns a raw HTMLelement.
Element(tag) Selector : similar to Id selector we can find an element by it's tag name. below are some examples :
above code will selects all table rows with in a able and alerts its html i.e. <td></td> tags.
Note: here we are not using # symbol with tag name.
above code will select all span, a and div elements from the document and changes its background color to yellow.
$('div a') = all a inside of div elements.
$('tr:even').css('background-color','gray')= set gray background of all even rows.
$('tr:odd').css('background-color','green')= sets green background of all odd rows.
we can also provide Id and then elements name like:
$('#table1 tr:even') = even rows of table whose id is 'table1'.
Class Selectors:
We can select elements by css class names.below are some examples:
$('.clsName) = will return all elements with css class named 'clsName'.
for example .small and .big are two css classes :
$('.small') =all elements with class '.small'.
$('.small,.big')=all elements with class small or class big.
$('.small.big') =all elements with class '.small' and'.big'.(both classes required)
$('.small .big')= all elements with .big class within elements with class'.small' (Space between classes)
$('div.small','.big') =all divs with class small and any other elements with class '.big'.
$('#container .small')= all elements inside container with class .small.