02.jQuery Syntax






jQuery Syntax

Basic syntax is: $(selector).action()

  • A $ sign to define/access jQuery
  • A (selector) to "query (or find)" HTML elements
  • A jQuery action() to be performed on the element(s)
Examples:

$(this).hide() - hides the current element.

$("p").hide() - hides all <p> elements.

$(".test").hide() - hides all elements with class="test".

$("#test").hide() - hides the element with id="test".


Document Ready Event

It is good practice to wait for the document to be fully loaded and ready before working with it. This also allows you to have your JavaScript code before the body of your document, in the head section.(Trying to hide an element that is not created yet)

$(document).ready(function(){ // jQuery methods go here...});

OR

$(function(){  // jQuery methods go here... });


Comments

Popular posts from this blog

09.Data Binding.

Database - Topics

02. Spring – Creating spring project clone it with GIT step by step.