...

Library - JQuery

Back to Course

Lesson Description


Lession - #557 JQuery Selectors


What are the selectors in JQuery?
jQuery selectors are used to "find" (or select>
HTML elements based on their name, id, classes, types, attributes, values of attributes and lots more. It`s based on the existing CSS Selectors, and in addition, it has a few own custom selectors.

Every jQuery selector begin with thiis signal $(>
. This signal is called the factory function. It makes use of the 3 primary building blocks while choosing an detail in a given document.

1>
Tag Name:
It represents a tag call available in the DOM.

For example: $(`p'>
selects all paragraphs'p'in the document.

2>
Tag ID:
It represents a tag available with a selected ID withinside the DOM.

For example: $('#real-id'>
selects a specific element withinside the document that has an ID of real-id.

3>
Tag Class:
It represents a tag to be had with a specific class in the DOM.

For example: $('real-class'>
selects all elements in the document which have a class of real-class.

Example


<html>  
<head> 
 <title> jQuery Example</title>  
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">  
 </script>  
 <script type="text/javascript" language="javascript">  
 $(document>
.ready(function(>
{ $("p">
.css("background-color", "green">
; }>
; </script> </head> <body> <p>techedhub.com.</p> </body> </html>
Try it here