How to include jQuery in an HTML page?

To include jQuery in an HTML page, you can follow these steps:

  1. Download the jQuery library from the official website or use a CDN (Content Delivery Network).

  2. Once you have the jQuery library file (usually named jquery.js or jquery.min.js), place it in a directory on your web server or in your project folder.

  3. In your HTML file, add a script tag inside the head or body section to include the jQuery library. You can either reference the local file or use a CDN.

    • For a local file:

      <script src="path_to_jquery/jquery.js"></script>
    • For a CDN (example using Google CDN):

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  4. After including the jQuery library, you can start using jQuery by writing your JavaScript code wrapped inside a script tag.

    <script> // Your jQuery code here </script>

Remember to place the script tag that includes jQuery before any other custom JavaScript code that relies on jQuery functions. This ensures that jQuery is available when your code is executed.