jQuery | Syntax - GeeksforGeeks

12 Apr, 2019
It is used for selecting elements in HTML and performing the action on those elements.
Syntax:
$(selector).action()
$ sign: It grants access to jQuery.
(selector): It is used to find HTML elements.
jQuery action(): It is used to perform actions on the elements.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.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.The shorter method for document ready:$(function(){

  // jQuery Method

});My Personal Notes
arrow_drop_upSave
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()
Used to hide the current element.$(this).hide()
$(this).hide()
Used to hide all <p> elements.$("p").hide()
$("p").hide()
Used to hide all elements with class=”test”.$(".test").hide()
$(".test").hide()
Used to hide the element with id=”test”.$("#test").hide()
$("#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.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.
$(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.
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.
The shorter method for document ready:$(function(){

  // jQuery Method

});
$(function(){

  // jQuery Method

});
jQuery-Basics
Picked
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
JQuery | Set the value of an input text field
How to change selected value of a drop-down list using jQuery?
Form validation using jQuery
How to change the background color after clicking the button in JavaScript ?
How to Dynamically Add/Remove Table Rows using jQuery ?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?