jQuery Syntax - CodingTuting


jQuery Basic Syntax
jQuery Syntax jQuery Tutorial CodingTuting.Com

Rules of jQuery
jQuery has only 2 rules -
  1. Initialize the jQuery
  2. Use the jQuery
The jQuery is perform well after the page is fully loaded. Because a web page can't be manipulated well without fully loaded.

1. Initialize the jQuery

    $(document).ready(function(){
        // Your Code
    });
jQuery first determine that the page (DOM) is fully loaded or not. The code under the above event function will executed only after the page (DOM) is fully loaded/ready.
jQuery has provided the alternate and shorter method of above event function. This is mostly use by the experienced developers.

$(function(){
    // Your Code
});

You can use any of the above event function for initialize the jQuery. But it is good practice to use the first one.


2. Use the jQuery

Syntax:
    $(selector).action();
The $ sign is use to access the jQuery.
selector is use to select the appropriate HTML element.
action() is the task which we want to perform.
Example:
    $(this).toggle();
    $("p").hide();
    $(".myClass").show();
    $("#myId").hide();
We will understand above all kinds of example in upcoming sections.


This is the syntax of a complete jQuery task

    $(document).ready(function(){
        $(selector).action();
    });

or

$(function(){
    $(selector).action();
});

We hope you got the basic syntax of the jQuery.
Please ask question in comment if you've any query.

Please share this article for support our website CodingTuting.Com


Thanks for Reading




Hi, I'm Jignesh Panchal. I'm a Web Developer & Designer. I've started this blog to help the programmers using my experience and skills. You will get solutions and tips about Programming, Web Development etc.

Share this

Related Posts