![]() |
jQuery Syntax jQuery Tutorial CodingTuting.Com |
Rules of jQuery
jQuery has only 2 rules -
- Initialize the jQuery
- Use the jQuery
1. Initialize the jQuery
$(document).ready(function(){ // Your Code });
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();
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();
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
EmoticonEmoticon