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 select 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 $(). In the parentheses may be an element, a class or an ID. For example:
$(“div”).action$(“.leftBorder”).action$(“#leftPanel”).action
So here we used the 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 is conflicting with something else then you can replace the $ sign with the jQuery name and you can use the function jQuery() instead of $(). Now let's implement jQuery with a small HTML code:The preceding code has the jQuery selector div when we applied these actions using CSS. The result will show the following:In a similar way 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:Result:Now let's use ID name as in the following:Result: So this was a simple concept of jQuery selectors. Selectors are very important and will be helpful at every step when using jQuery. There are many important things that can help you better understand jQuery selectors.
You can use all the selectors shown above with any HTML tag. Do more practice, you will get more clarification. Comment here if you have any problem in jQuery Selectors.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: