
Quiz in Jquery
Here�s a jQuery Quiz to test your knowledge! These questions cover key concepts like syntax, methods, events, and more.
1. What does the $
symbol represent in jQuery?
a) A variable
b) A function
c) A jQuery object selector
d) A CSS property
2. Which of the following methods is used to hide an element in jQuery?
a) .show()
b) .display()
c) .hide()
d) .fade()
3. How do you change the background color of a div with ID #myDiv
to blue in jQuery?
a) $("#myDiv").css("background-color", "blue");
b) $("#myDiv").style("background-color", "blue");
c) $("#myDiv").change("background-color", "blue");
d) $("#myDiv").background("blue");
4. Which jQuery method is used to attach an event handler to an element?
a) .on()
b) .event()
c) .bind()
d) .attach()
5. How can you select all paragraphs (
) inside a div with class .container
in jQuery?
a) $(".container p")
b) $("div p")
c) $(".container").find("p")
d) All of the above
6. What does the .each()
function do in jQuery?
a) Iterates through an array or object
b) Selects elements based on a condition
c) Changes the style of elements
d) Creates a new HTML element
7. How can you load content into a div with ID #result
from a server in jQuery?
a) $("#result").get("content.php");
b) $("#result").load("content.php");
c) $("#result").ajax("content.php");
d) $("#result").request("content.php");
8. Which method is used to get the value of an input field in jQuery?
a) .value()
b) .input()
c) .val()
d) .text()
9. What does the $.noConflict()
method do?
a) It prevents multiple jQuery versions from running
b) It releases control of the $
symbol so other libraries can use it
c) It fixes conflicts between HTML and CSS
d) It handles conflicts in JavaScript variables
10. How can you change the text of an element with ID #example
in jQuery?
a) $("#example").text("New Text");
b) $("#example").html("New Text");
c) Both a and b
d) $("#example").change("New Text");
Answer Key:
c) A jQuery object selector
c)
.hide()
a)
$("#myDiv").css("background-color", "blue");
a)
.on()
d) All of the above
a) Iterates through an array or object
b)
$("#result").load("content.php");
c)
.val()
b) It releases control of the
$
symbol so other libraries can use itc) Both a and b