What is JQuery? Write its features and Write a program to display a message "Hello Class 12" using JQuery.

 jQuery



 jQuery is a fast, small, and feature-rich JavaScript library that simplifies and enhances client-side web development. It provides a comprehensive set of functions and utilities for DOM manipulation, event handling, animations, AJAX requests, and more. jQuery aims to streamline JavaScript code and improve cross-browser compatibility, allowing developers to write concise and efficient code for building interactive and dynamic web applications.


Key features of jQuery include:


1. **DOM Manipulation**:

 jQuery simplifies DOM manipulation by providing methods to select and modify HTML elements, attributes, styles, and content.


2. **Event Handling**: 

jQuery allows developers to easily attach event handlers to HTML elements and respond to user interactions such as clicks, keypresses, mouse movements, and form submissions.


3. **AJAX Support**: 

jQuery simplifies asynchronous communication with web servers using AJAX (Asynchronous JavaScript and XML) requests. It provides methods for making AJAX calls, handling responses, and updating page content dynamically without reloading the entire page.


4. **Animations**: 

jQuery includes built-in animation effects and methods for creating smooth transitions, fades, slides, and other visual effects on web pages.


5. **Utility Functions**:

 jQuery provides a wide range of utility functions for manipulating arrays, working with objects, handling data types, and performing various common tasks in web development.


Here's an example of how to display the message "Hello Class 12" using jQuery:


html

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Hello Class 12</title>

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

</head>

<body>


<div id="message"></div>


<script>

// Wait for the document to be ready

$(document).ready(function() {

    // Select the div element with id "message" and set its text content to "Hello Class 12"

    $('#message').text('Hello Class 12');

});

</script>


</body>

</html>

```


In this example:

- We include the jQuery library by adding a `<script>` tag with the source URL pointing to the jQuery CDN (Content Delivery Network).

- Inside a `<script>` tag, we use jQuery's `$(document).ready()` function to wait for the document to be fully loaded before executing any JavaScript code.

- Within the `$(document).ready()` function, we use the jQuery selector `$('#message')` to select the div element with the id "message".

- We then use the `.text()` method to set the text content of the selected element to "Hello Class 12".


When the web page is loaded, the jQuery code is executed, and the message "Hello Class 12" is displayed inside the `<div>` element with the id "message".

Post a Comment

0 Comments