Quick Contact

    Downloading jQuery

    To begin, obtain a copy of jQuery and incorporate it into the document. jQuery is available in two versions for download.

    — compressed and uncompressed.

    The unencrypted file is ideal for advancement or bug fixing, whereas the minified and squeezed file is ideal for production because it saves precious frequency band and performs better due to the small file size.

    You can download jQuery from here: https://jquery.com/download/

    Once you’ve downloaded the jQuery file you can see it has .js extension, because the jQuery is just a JavaScript library, therefore you can include the jQuery file in your HTML document with the < script> element just like you include normal JavaScript files.

    Code

    < !DOCTYPE html>
    < html lang="en">
    < head>
    < meta charset="utf-8">
    < title>My First jQuery Application< /title>
    < link rel="stylesheet" type="text/css" href="/examples/css/style.css">
    < scriptsrc="https://code.jquery.com/jquery-3.5.1.min.js">< /script>
    < /head>
    < body>
    < h1>Hello, World!< /h1>
    < /body>
    < /html>
    

    Output

    Hello, World!

    Always include the jQuery file before your custom scripts; otherwise, the jQuery APIs will not be available when your jQuery code attempts to access it.

    Including jQuery from CDN

    If you don’t want to download and streaming server jQuery home improvement, you can include it in the document using freely available CDN (Content Delivery Network) links.

    CDNs can improve performance by minimizing page load time because they host jQuery on numerous servers around the world, and when a client requests the file, it is served from the server closest to them.

    This also comes with the benefits of not having to re-download jQuery if the visitor to the document has already downloaded a copy from the same CDN while visiting other sites.

    jQuery’s CDN provided by StackPath

    < script src=”https://code.jquery.com/jquery-3.5.1.min.js”>< /script>

    You can also use the Google and Microsoft CDNs to include jQuery.

    Creating Your First jQuery Powered Web Page

    So far, you’ve learned about the functions of the jQuery library and how to integrate it into the document; now it’s time to put jQuery to use.

    In this section, we’ll do a simple jQuery operation to change the color of the heading text from black to red.

    Example

    < !DOCTYPE html>
    < html lang="en">
    < head>
    < meta charset="utf-8">
    < title>Example of Simple jQuery Powered Web Page< /title>
    < link rel="stylesheet" type="text/css" href="/examples/css/style.css">
    < scriptsrc="https://code.jquery.com/jquery-3.5.1.min.js">< /script>
    < script>
            $(document).ready(function(){
                $("h1").css("color", "#0088ff");
            });
    < /script>
    < /head>
    < body>
    < h1>Ducat India< /h1>
    < /body>
    < /html>
    

    Output

    Ducat India

    In the previous example, we used the jQuery element selector and the css() method to change the color of the heading, i.e. the < h1> element, whenever the document has beenprepared, which would be known as the document ready event.

    Copyright 1999- Ducat Creative, All rights reserved.

    Anda bisa mendapatkan server slot online resmi dan terpercaya tentu saja di sini. Sebagai salah satu provider yang menyediakan banyak pilihan permainan.