jQuery getting started

Last Updated: November 3, 2021

Getting started with jQuery is simple.

<!doctype html>
    <meta charset="utf-8">
    <a href="http://jquery.com/">jQuery</a>
    <script src="jquery.js"></script>
    // Your code goes here.

You can download the latest version of the jQuery from https://jquery.com/download/

Launching Code on Document Ready

You can run the JS code inside onload() function or document.ready() function

window.onload = function() {
    alert( "welcome" );

Here is the document.ready()

$( document ).ready(function() {
    alert( "welcome" );

ready event will run your code fast.

Sample code for the click event

$( document ).ready(function() {
    $( "a" ).click(function( event ) {
        alert( "As you can see, the link no longer took you to jquery.com" );