HOME C C++ PYTHON JAVA HTML CSS JAVASCRIPT BOOTSTRAP JQUERY REACT PHP SQL AJAX JSON DATA SCIENCE AI

jQuery Syntax

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.
  • $(selector).action()

$(selector).action()

  • Used to hide all

    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.

$(function(){ // jQuery Method });