How to use jQuery Selectors with Examples
To work with an element on the web page, first we need to find them. To find the html element in jQuery we use selectors. jQuery provides many selectors out of the box. Let me explain some of the very useful selectors in “how to” ways. How to select all elements of the page? - All Selector (“*”) To select all elements of the page, we can use all selectors, for that we need to use *(asterisk symbol). <script language="javascript" type="text/javascript"> $("*").css("border", "5px dashed green"); </script> Above code will select all elements of the web page and apply border width as 5 pixel, style as dashed and color as green. How to select a particular element having a specific class? - Class Selector (“.class”) To select an element with a specific class, class selector can be used. We need to prefix the class name with “.” (dot). <script language="javascript" type="text/javascript"> $(".clas...