Explain important Jquery selectors? (Jquery Interview Questions)
You can select HTML elements using Jquery in the following ways:-
Below is a simple code snippet which selects all elements and hides them.
Select by Element
Below code selects all paragraph element tags in the HTML and hides them.
Select by ID
If your HTML elements have id's like the below HTML code and you want to select the same by id.
Below is how the Jquery code by ID selection code would look like.
Select by class
If your HTML element has class names and you want to select them in jquery using them you need use the dot followed by the classname as shown in the below code.
Select by class and element
Consider the below HTML code where we have elements with "class" names.
So if you wish to select by "element" and "class" in Jquery your selector code becomes something as below.
Below is youtube video created by questpond.com team who provide .NET Learning videos for interview preparation. The below video explains what is Jquery with simple example.