jQuery Syntax

In this tutorial you will learn about jQuery Syntax, when we create jQuery Syntax to select element and performing a action step by step.

What is jQuery Syntax?

Basically jQuery is select and manipulating html element, performing some easy and difficult action on element which called jQuery Syntax.

$(selector).action()

upon the given $ sign know as define/access jQuery, (selector) denote find html element, action() denote what you want to perfome action like hide or show and other action method.

Example: using element selector

$("p").hide()
  • p denotes all paragraph <p>
  • hide() is action method
  • it mean that hide all paragraph in web page.

Example: using class selector

$(".my_class").hide()
  • .my_class is class selector which will be hide

Example: using Id selector

$("#my_Id").hide()
  • #my_Id is Id selector which will be hide

How to Write Document Ready Event

If you want to write jQuery method then you need to write it first, all jquery method will be written under document ready.

<script>
$(document).ready(function(){

  // Here you can write jQuery Method...

});
</script>

upon the given Document Ready Even means that when page is ready to show content then this event excute.

Other hand this method waits for the page to load, this event is not executed until the page is loaded.

You can write another way to Document ready event

<script>
$(function(){

  // Here you can write jQuery Method...

});
</script>

There is a reason behind this method because it is impossible to find any element loaded without a document and apply an action method to it.