Wednesday, 29 April 2015

jQuery Syntax

With jQuery, we can select HTML elements and perform some actions in it.

jQuery Syntax

The jQuery syntax is used to select the HTML elements and perform some action in it.

The Basic Syntax is : $(selector).action()
  • The $ sign is used to define or access jQuery
  • The (selector) is used to find or select HTML elements.
  • The action() is the jQuery action to be performed in the HTML element.
For example:
$("p").hide()

The Document Ready Event

The document ready event is used to prevent any jQuery code from running before the document had finished loading. It is good practice for the document to be loaded before working with it. This also allows you to place the jQuery code before the body of the document, that is in the head section.

For example:
$ (document).ready(function() {
   // jQuery method goes here...
});

The jQuery team has also created an even shorter method for the document ready event.

For example:
$ (function () {
   // jQuery method goes here...
});

Related Posts:

  • What is HTML? HTML is a most commonly used language for designing websites. Today HTML language is being taught at young age onwards. This language is user-friendl… Read More
  • HTML Sections HTML elements can be grouped together for various content. Some of the common used tags are <div> and <span>. We can use <div> to … Read More
  • HTML Text Formatting HTML has different tags for different purpose. One such purpose is formatting text. In HTML, we can give headings, give styles to text and so on. It … Read More
  • What is Bootstrap? Bootstrap is a powerful free front-end framework for faster and better web development. Bootstrap includes HTML and also CSS based designs for typogr… Read More
  • HTML Head and Body The <head> tag and the <body> tag arethe two important tags used in HTML document. Both of them are essential in creating an HTML documen… Read More

0 comments:

Post a Comment