jQuery Exam Question and Answer

 




1. What is jQuery?

A) A programming language

B) A JavaScript library

C) A database management system

D) An operating system

 

Answer: B) A JavaScript library

 

2. Which symbol is commonly used to represent jQuery?

A) $

B) #

C) &

D) %

 

Answer: A) $

 

3. Which function is used to select elements with a specific CSS class in jQuery?

A) getElementById()

B) getElementByClass()

C) find()

D) $(".classname")

 

Answer: D) $(".classname")

 

4. Which of the following is NOT a method of jQuery?

A) append()

B) insertBefore()

C) replaceWith()

D) getElementById()

 

Answer: D) getElementById()

 

5. Which method is used to hide an element in jQuery?

A) show()

B) display()

C) visible()

D) hide()

 

Answer: D) hide()

 

6. What is the function of the $(document).ready() method in jQuery?

A) It waits for the DOM to be fully loaded before executing code.

B) It selects all document elements.

C) It executes code immediately after page load.

D) It checks if the document is ready for printing.

 

Answer: A) It waits for the DOM to be fully loaded before executing code.

 

7. Which jQuery method is used to perform an asynchronous HTTP request?

A) $.get()

B) $.ajax()

C) $.post()

D) $.load()

 

Answer: B) $.ajax()

 

8. What does AJAX stand for?

A) Asynchronous JavaScript and XML

B) All JavaScript and XHTML

C) Asynchronous jQuery and XML

D) Advanced JavaScript and XHTML

 

Answer: A) Asynchronous JavaScript and XML

 

9. Which jQuery method is used to set one or more style properties for selected elements?

A) css()

B) style()

C) setStyle()

D) property()

 

Answer: A) css()

 

10. Which jQuery method is used to add one or more classes to selected elements?

A) addClass()

B) appendClass()

C) insertClass()

D) modifyClass()

 

Answer: A) addClass()

 

11. What does the .text() method in jQuery do?

A) Sets the HTML content of an element

B) Gets the combined text contents of each element in the set of matched elements

C) Toggles the visibility of an element

D) Removes the selected element from the DOM

 

Answer: B) Gets the combined text contents of each element in the set of matched elements

 

12. Which jQuery method is used to remove selected elements and its data?

A) clear()

B) delete()

C) remove()

D) destroy()

 

Answer: C) remove()

 

13. Which jQuery method is used to stop the currently running animations on the selected elements?

A) halt()

B) stop()

C) cancel()

D) pause()

 

Answer: B) stop()

 

14. What is the function of the .attr() method in jQuery?

A) It adds a new attribute to selected elements

B) It removes an attribute from selected elements

C) It retrieves the value of an attribute for the first element in the set of matched elements

D) It modifies the value of an attribute for the selected elements

 

Answer: C) It retrieves the value of an attribute for the first element in the set of matched elements

 

15. Which jQuery method is used to traverse the DOM and get the parent element of a selected element?

A) parent()

B) getParent()

C) findParent()

D) getParentElement()

 

Answer: A) parent()

 

16. Which of the following is a valid way to include jQuery in an HTML document?

A) <script src="jquery.js"></script>

B) <link rel="stylesheet" href="jquery.css">

C) <script type="text/javascript" src="jquery.js"></script>

D) <script>include("jquery.js")</script>

 

Answer: C) <script type="text/javascript" src="jquery.js"></script>

 

17. Which symbol is used to represent the jQuery object?

A) #

B) $

C) @

D) &

 

Answer: B) $

 

18. Which method is used to bind an event handler to the "click" JavaScript event in jQuery?

A) .on()

B) .click()

C) .bind()

D) .handle()

 

Answer: B) .click()

 

19. What is the purpose of chaining in jQuery?

A) To combine multiple elements into one

B) To combine multiple jQuery functions in a single statement

C) To prevent certain functions from executing

D) To split a single jQuery function into multiple steps

 

Answer: B) To combine multiple jQuery functions in a single statement

 

20. Which jQuery method is used to append content to the end of selected elements?

A) append()

B) prepend()

C) after()

D) before()

 

Answer: A) append()

 

21. What is the use of the .each() method in jQuery?

A) It adds an event listener to each element in a set of matched elements.

B) It iterates over a jQuery object, executing a function for each matched element.

C) It removes all matched elements from the DOM.

D) It checks if any of the matched elements is hidden.

 

Answer: B) It iterates over a jQuery object, executing a function for each matched element.

 

22. Which jQuery method is used to get the width of an element?

A) width()

B) getWidth()

C) clientWidth()

D) offsetWidth()

 

Answer: A) width()

 

23. Which jQuery method is used to determine whether the selected elements contain any content?

A) isEmpty()

B) hasContent()

C) isNotEmpty()

D) is()

 

Answer: D) is()

 

24. What is the purpose of the .fadeOut() method in jQuery?

A) To fade in selected elements

B) To fade out selected elements

C) To toggle the visibility of selected elements

D) To slide up selected elements

 

Answer: B) To fade out selected elements

 

25. Which jQuery method is used to perform a specific action for each matched element?

A) map()

B) forEach()

C) each()

D) loop()

 

Answer: C) each()

 

26. What is the use of the .slideDown() method in jQuery?

A) To slide up selected elements

B) To slide down selected elements

C) To fade in selected elements

D) To fade out selected elements

 

Answer: B) To slide down selected elements

 

27. Which jQuery method is used to toggle between hiding and showing elements?

A) toggleHide()

B) toggle()

C) switch()

D) swap()

 

Answer: B) toggle()

 

28. What is the purpose of the .hasClass() method in jQuery?

A) To add a class to selected elements

B) To remove a class from selected elements

C) To check if selected elements have a specific class

D) To toggle a class on selected elements

 

Answer: C) To check if selected elements have a specific class

 

29. Which jQuery method is used to animate selected elements?

A) move()

B) animate()

C) transition()

D) effect()

 

Answer: B) animate()

 

30. What does the $('selector').length return in jQuery?

A) Number of elements matching the selector

B) Number of characters in the selector

C) Number of classes applied to the elements

D) Number of methods applied to the elements

 

Answer: A) Number of elements matching the selector

 

31. Which jQuery method is used to get the height of an element?

A) height()

B) getHeight()

C) clientHeight()

D) offsetHeight()

 

Answer: A) height()

 

32. What is the purpose of the .serialize() method in jQuery?

A) To convert a form's data into a string of URL-encoded key-value pairs

B) To retrieve the serialized form of selected elements

C) To serialize a jQuery object into a JSON string

D) To convert a string of URL-encoded key-value pairs into a JSON object

 

Answer: A) To convert a form's data into a string of URL-encoded key-value pairs

 

33. Which jQuery method is used to check if an element has a particular event handler attached to it?

A) hasEventListener()

B) hasHandler()

C) isHandlerAttached()

D) has()

 

Answer: D) has()

 

34. What does the .empty() method do in jQuery?

A) Removes the selected elements from the DOM

B) Clears the content of selected elements

C) Removes all event handlers attached to the selected elements

D) Hides the selected elements

 

Answer: B) Clears the content of selected elements

 

35. Which jQuery method is used to retrieve the current position of an element relative to the document?

A) position()

B) getPosition()

C) offset()

D) getOffset()

 

Answer: C) offset()

 

36. What is the purpose of the .fadeIn() method in jQuery?

A) To fade out selected elements

B) To fade in selected elements

C) To slide up selected elements

D) To slide down selected elements

 

Answer: B) To fade in selected elements

 

37. Which jQuery method is used to determine whether an element is visible or hidden?

A) isVisible()

B) displayStatus()

C) isHidden()

D) is()

 

Answer: A) isVisible()

 

38. What is the purpose of the .slideUp() method in jQuery?

A) To slide down selected elements

B) To slide up selected elements

C) To fade out selected elements

D) To fade in selected elements

 

Answer: B) To slide up selected elements

 

39. Which jQuery method is used to select the immediate child elements of a parent element?

A) children()

B) getChildElements()

C) findChildren()

D) getChildNodes()

 

Answer: A) children()

 

40. What does the .html() method do in jQuery?

A) Sets the HTML content of selected elements

B) Gets the HTML content of selected elements

C) Clears the HTML content of selected elements

D) Checks if selected elements have HTML content

 

Answer: B) Gets the HTML content of selected elements

 

41. Which jQuery method is used to remove all child nodes and content of the selected elements?

A) empty()

B) clear()

C) erase()

D) removeChildren()

 

Answer: A) empty()

 

42. What is the purpose of the .slideDown() method in jQuery?

A) To slide up selected elements

B) To slide down selected elements

C) To fade out selected elements

D) To fade in selected elements

 

Answer: B) To slide down selected elements

 

43. Which jQuery method is used to get the index of an element within its parent?

A) getIndex()

B) index()

C) getPosition()

D) getChildIndex()

 

Answer: B) index()

 

44. What is the function of the .stop() method in jQuery animation?

A) It starts the animation.

B) It pauses the animation.

C) It stops the animation.

D) It reverses the animation.

 

Answer: C) It stops the animation.

 

45. Which jQuery method is used to bind one or more event handlers to elements?

A) attach()

B) bind()

C) listen()

D) event()

 

Answer: B) bind()

 

46. What is the purpose of the .addClass() method in jQuery?

A) To add a CSS class to selected elements

B) To remove a CSS class from selected elements

C) To toggle a CSS class on selected elements

D) To check if selected elements have a specific CSS class

 

Answer: A) To add a CSS class to selected elements

 

47. Which jQuery method is used to retrieve the value of an input field?

A) getValue()

B) value()

C) val()

D) retrieveValue()

 

Answer: C) val()

 

48. What does the .animate() method in jQuery do?

A) It applies CSS animations to selected elements.

B) It animates the changes of selected elements over time.

C) It creates new elements with animations.

D) It stops all animations on selected elements.

 

Answer: B) It animates the changes of selected elements over time.

 

49. Which jQuery method is used to perform an HTTP GET request?

A) $.ajaxGet()

B) $.get()

C) $.fetch()

D) $.request()

 

Answer: B) $.get()

 

50. What is the purpose of the .serializeArray() method in jQuery?

A) To serialize form data into an array of objects

B) To deserialize JSON data into an array

C) To convert an array into a serialized string

D) To remove empty elements from an array

 

Answer: A) To serialize form data into an array of objects

No comments:

Post a Comment