Introduction
As in our Day 1 and Day 2 lessons, we know jQuery is a special library of JavaScript. This library harnesses the power of CSS selectors to let us quickly and easily access elements or groups of elements in the Document Object Model (DOM). We know the basic syntax of jQuery is as in the following,
$(selector).action()
Now let's learn more about this syntax. jQuery selectors are used to selecting one or more HTML elements using jQuery. Once an element is selected, we can do various operations on that selected element. A selector starts with $(). The parentheses may be an element, a class, or an ID. For example,
<div class=”leftBorder”> C# Corner</div>
<div ID=”leftPanel”>C# Corner</div>
For the preceding code, jQuery syntax (for selectors ) will be,
$(“div”).action
$(“.leftBorder”).action
$(“#leftPanel”).action
So here we used three things, HTML tag name, class name, and ID name. There are jQuery selectors. The factory function $() is a synonym of the jQuery() function. So in case, you are using any other JavaScript library where a $ sign conflicts with something else, you can replace the $ sign with the jQuery name and use the function jQuery() instead of $(). Now let's implement jQuery with a small HTML code,
<html>
<head>
<title>jQuery Selectors</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() {
$("div").css("background-color", "red");
}); </script>
</head>
<body>
<div>
This is third paragraph.
</div>
</body>
</html>
When we applied these actions using CSS, the preceding code has the jQuery selector div. The result will show the following,

Similarly, we can use the class name and ID name. Now here we are using the class name "myParagrapg". We will get the same result as in the following,
<head>
<html>
<title>jQuery Selectors</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() {
$(".myParagraph").css("background-color", "red");
}); </script>
</head>
<body>
</body>
</html>
<div class="myParagraph">
This is third paragraph. (Using Class Name)
</div>


Santhakumar MunuswamyPosted Jul 3, 2015, 3:07 PM
Thanks for nice article.:)
Gopi ChandPosted Jul 1, 2015, 1:25 PM
Great work
Debasis SahaPosted Jul 1, 2015, 10:37 AM
Nice article
Saineshwar BageriPosted Jul 1, 2015, 9:49 AM
good start