jQuery | Syntax
It is used for selecting elements in HTML and performing the action on those elements.
Syntax:
$(selector).action()
- Used to hide the current element.
$(this).hide()
- Used to hide all <p> elements.
$("p").hide() - Used to hide all elements with class=”test”.
$(".test").hide() - Used to hide the element with id=”test”.
$("#test").hide()
Document Ready Event:
-
jQuery Methods are inside a Document ready event for easy reading of code.
$(document).ready(function(){ // jQuery Method });This is to check and stop the jquery before the document is finished loading. This method also allows you to have JavaScript code before the body of your document, in the head section.
- The shorter method for document ready:
$(function(){ // jQuery Method });
Some actions that can fail if the method is run before the loaded document:
Get the image size which is not loaded or hide element which is not created yet.
Recommended Posts:
- XML | Syntax
- PHP | Basic Syntax
- CSS | Syntax and Selectors
- JavaScript | Syntax
- Ruby Basic Syntax
- Placeholder Syntax in Scala
- jQuery | jQuery.support Property
- jQuery | jQuery.fx.interval Property with example
- jQuery | jQuery.fx.off Property
- jQuery | jquery Property
- jQuery | css()
- jQuery | die() Method
- jQuery | after() with Examples
- jQuery | :has() Selector with example
- jQuery | #id Selector
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



