jQuery HOME

Welcome to the jQuery Tutorial! This section introduces you to jQuery, a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and AJAX much simpler with an easy-to-use API that works across a multitude of browsers.

What is jQuery?

  • jQuery is a JavaScript library designed to simplify HTML DOM tree traversal and manipulation, as well as event handling, CSS animation, and AJAX.
  • It is free, open-source software licensed under the MIT License.

Why Use jQuery?

  • Cross-Browser Compatibility: jQuery handles many cross-browser issues and provides a consistent experience.
  • Simplified Syntax: jQuery provides a simple syntax to achieve complex functionalities with minimal code.
  • Rich Features: It supports event handling, animations, and AJAX, making it a powerful tool for web development.
  • Community and Plugins: A vast community and a plethora of plugins enhance jQuery’s capabilities.

Getting Started with jQuery

  1. Include jQuery in Your Project:
    • Using a CDN:
      <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
      

      Try It Now

    • Download and Include: Download jQuery from the official website and include it in your project directory:
      <script src="path/to/jquery-3.6.0.min.js"></script>
      

      Try It Now

  2. Basic jQuery Example: In the example above, jQuery is used to hide a paragraph when the button is clicked.
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>jQuery Example</title>
        <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
        <script>
            $(document).ready(function(){
                $("button").click(function(){
                    $("p").hide();
                });
            });
        </script>
    </head>
    <body>
        <p>This is a paragraph.</p>
        <button>Click me to hide the paragraph</button>
    </body>
    </html>
    

    Try It Now

Key Concepts in jQuery

  • Selectors: jQuery selectors allow you to select and manipulate HTML elements.
  • Events: jQuery makes it easy to handle events, such as clicks and key presses.
  • Effects: jQuery provides various methods to create animations and effects.
  • AJAX: jQuery simplifies AJAX calls, making asynchronous requests to the server effortless.