Explain important Jquery selectors? (Jquery Interview Questions)
- By Shiv Prasad Koirala in .Net
- Jun 5th, 2014
- 10
- 0
You can select HTML elements using Jquery in the following ways:-
Select
all
Below is a simple code snippet which selects all elements and hides them.
$("*").hide();
Select by Element
Below code selects all paragraph element tags in the HTML and hides them.
$("p").hide();
Select by ID
If your HTML elements have id's like the below HTML code and you want to select the same by id.
<p id="p1">Some Para</p>
Below is how the Jquery code by ID selection code would look like.
$("#p1").hide();
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.
<p class="class1">Some Para</p>
$(".class1").hide()
Select by class and element
Consider the below HTML code where we have elements with "class" names.
<p class="c1">para 1</p>
<p class="c1">para 2</p>
<p class="c2">para 2</p>
<p class="c2">para 2</p>
So if you wish to select by "element" and "class" in Jquery your selector code becomes something as below.
$("p.c1").hide();
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.
Shiv Prasad Koirala
Visit us @ www.questpond.com or call us at 022-66752917... read more

- By Shiv Prasad Koirala
- Jun 20th, 2012
- 59
- 0
C# threading interview questions: - What is the difference between

- By Shiv Prasad Koirala
- Feb 16th, 2013
- 55
- 0
.NET interview questions and answers: - What is TPL?

- By Shiv Prasad Koirala
- Sep 12th, 2013
- 49
- 0
What is Jquery ? ( ASP.NET Jquery interview questions with answers)

- By Shiv Prasad Koirala
- Jun 4th, 2012
- 32
- 0