Search within TutorialsPark

Jquery Syntax


Understand the Syntax and meaning of your Jquery Code.


Jquery Syntax : the $(..) function

To use Jquery you need to gain access to the Jquery library first, this is done using the function jquery().

However, the same function can be performed using the shortcut $(..)

A Standard Jquery Syntax is as given below:

$ ( "selector").operation()
  • $() : To call the Jquery Library.
  • selector : The selector to select the element on which the Jquery operation will be performed.
  • operation; : The operation to be performed on the selected item.

Applying Jquery to HTML Document

The demo below uses the Jquery selector $(..) to select element and then perform some operations on it

Syntax: Jquery$(..) function

Example: Jquery $(..) Selector

Give it a TRY! » Note:Hover mouse over the image to remove the opacity


Jquery Syntax: Using the jquery() Function

There are many other JavaScript libraries that use the $ function to gain access to their libraries, to avoid conflict you can relinquish control of the $ by making use of the method jQuery.noConflict

Instead of using the shorthand notation you can also use the function jQuery() to gain access to the jquery library.

Syntax: Jquery Syntax using jQuery() function

Example: Jquery Syntax using jQuery() function

Give it a TRY! » Note:Hover mouse over the image to remove the opacity


Jquery Syntax : Using your own custom Shorthand

jQuery even allows users to use your own custom shorthand , this is achieved by assigning the result of the jQuery.noConflict() to a custom variable, and then use the variable thoughout the script.

Syntax: Jquery Custom Shorthand

Example: Jquery custom Shorthand

Give it a TRY! » Note:Hover mouse over the image to remove the opacity


Note:Throughout the Website we will the $ notation to gain access to Jquery Library.

Table : Jquery Function Arguments

Name Description
$(function) To specify the function to be executed when the DOM is ready
$(selector)
$(selector, context)
To select the element
$(HTMLElement)
$(HTMLElement[])
To create a jQuery object from an HTMLElement or to create an HTMLElement object
$() To create an empty Selection
$(HTML) To create a new element from a fragment of HTML