jQuery Syntax

jQuery Syntax : The Basic Idea about jQuery is to select the element(s) and perform the action on them. For selecting elements the selectors are used.

jQuery Syntax


The $ symbol is used to access the jQuery.
The basic example for jquery selector and action :


selector is used to select the element from the dom.
.action() performs the action on the selected element.


jQuery Basic Example :

<!DOCTYPE html>
<title>jQuery CDN Example</title>
 <script type="text/javascript" src="//code.jquery.com/jquery-2.1.4.min.js">
<script type="text/javascript">
<div class="test"> 
This id test div .....and background is added using jquery...

Try it »


jquery basic syntax

jquery basic syntax

jQuery $(document).ready method

jQuery document ready event is used to prevent code run while your document ie. page is loading. It runs the code only when your document is completely loaded and ready.
This is used because some elements ie. selectors are created later in that case your code will not work for those

Best Example can suppose your code run first in head section and your element is loaded in footer later, in this case your code will not work.

example of document ready method :

          // write your code here...

or you can also use

          // write your code here...


Add Comment

📖 Read More