jQuery Question and Answer Interview & Exam Preparation
1. What is jQuery?
Answer:
jQuery is a fast, lightweight, and feature-rich JavaScript library. It simplifies HTML document traversal, event handling, animation, and AJAX interactions for rapid web development.
2. Why do we use jQuery?
Answer:
We use jQuery to:
-
Simplify JavaScript coding
-
Handle events easily
-
Perform animations
-
Make AJAX requests
-
Manipulate DOM elements
-
Ensure cross-browser compatibility
3. What is the difference between JavaScript and jQuery?
Answer:
-
JavaScript is a programming language.
-
jQuery is a library built using JavaScript.
-
jQuery makes JavaScript tasks easier and shorter.
Example:
JavaScript:
jQuery:
4. How to include jQuery in a website?
Answer:
You can include jQuery using a CDN link:
5. What is $(document).ready() function?
Answer:
It ensures that the code runs only after the HTML document is fully loaded.
6. What are jQuery Selectors?
Answer:
Selectors are used to select HTML elements.
Examples:
-
$("#id")→ Select by ID -
$(".class")→ Select by class -
$("p")→ Select all paragraphs
7. What is the use of .hide() and .show()?
Answer:
These methods hide and show elements.
8. What is jQuery AJAX?
Answer:
AJAX allows loading data from the server without refreshing the page.
9. What is the difference between .html() and .text()?
Answer:
-
.html()sets or returns HTML content. -
.text()sets or returns only text content.
10. What is chaining in jQuery?
Answer:
Chaining allows multiple jQuery methods on the same element.
11. What are jQuery Events?
Answer:
Events are actions like:
-
click()
-
dblclick()
-
mouseenter()
-
mouseleave()
-
keypress()
Example:
12. What is the use of addClass() and removeClass()?
Answer:
-
addClass()adds CSS class -
removeClass()removes CSS class
13. What is the latest version of jQuery?
Answer:
The latest stable version (as of recent updates) is jQuery 3.x series.
14. What is the difference between == and === in jQuery/JavaScript?
Answer:
-
==compares value only -
===compares value and data type
15. Is jQuery still used today?
Answer:
Yes, jQuery is still used in many websites, especially legacy projects. However, modern frameworks like React, Angular, and Vue are more popular for large applications.
Categories: web designing jquery