Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • jQuery Tutorial
  • jQuery Selectors
  • jQuery Events
  • jQuery Effects
  • jQuery Traversing
  • jQuery HTML & CSS
  • jQuery AJAX
  • jQuery Properties
  • jQuery Examples
  • jQuery Interview Questions
  • jQuery Plugins
  • jQuery Cheat Sheet
  • jQuery UI
  • jQuery Mobile
  • jQWidgets
  • Easy UI
  • Web Technology
Open In App
Next Article:
jQuery queue() Method
Next article icon

jQuery hide() Method

Last Updated : 17 Sep, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

The jQuery hide() method is used to hide selected HTML elements with a smooth animation effect. It reduces the element’s height to zero, effectively making it invisible. The method can also take a duration parameter to control the speed of the hiding animation.

Syntax:

$(element_selector).hide(duration, easing, call_function);

Parameter: It accepts three parameters which are specified below-

  • duration: It specifies the speed of the hide effect.
  • easing: It specifies the speed of the element at different points of animation.
  • call_function: This is the call-back function to be executed after the hide operation.

Return Value: It does not return any value.

Example 1: In the we use jQuery to hide a paragraph when a button is clicked. It also styles a div with a green border, padding, and adjusts the button’s margin for spacing.

HTML
<!DOCTYPE html> <html>  <head>     <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">     </script>     <!-- jQuery code to show the working of this method -->     <script>         $(document).ready(function () {             $(".b1").click(function () {                 $("p").hide();             });         });     </script>     <style>         div {             width: 50%;             height: 80px;             padding: 20px;             margin: 10px;             border: 2px solid green;             font-size: 30px;         }          .b1 {             margin: 10px;         }     </style> </head>  <body>     <div>         <p>GeeksforGeeks !.</p>     </div>     <!-- click on this button and          above paragraph will disappear -->     <button class="b1">Click me !</button>  </body>  </html> 

Output: 

Example 2: In the below example, we use jQuery to hide a paragraph when a button is clicked. The paragraph hides over 1000 milliseconds, and an alert message appears once the hide animation is complete.

HTML
<!DOCTYPE html> <html>  <head>     <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">     </script>     <!--jQuery code to show the working of this method-->     <script>             $(document).ready(function () {                 $(".btn1").click(function () {                     $("p").hide(1000, function () {                         alert("Hide() method has finished its working!");                     });                 });             });     </script>     <style>         p {             width: 40%;             padding: 20px;             height: 50px;             border: 2px solid green;         }     </style> </head>  <body>     <p>GeeksforGeeks.!</p>     <!-- click on this button and          above paragraph will hide -->     <button class="btn1">Click to Hide</button> </body>  </html> 

Output: 



Next Article
jQuery queue() Method

K

kundankumarjha
Improve
Article Tags :
  • JavaScript
  • JQuery
  • Web Technologies
  • jQuery-Effects
  • jQuery-Methods

Similar Reads

  • jQuery animate() Method
    The animate() method is an inbuilt method in jQuery which is used to change the state of the element with CSS style. This method can also be used to change the CSS property to create the animated effect for the selected element. Syntax: (selector).animate({styles}, para1, para2, para3); Here "select
    2 min read
  • jQuery clearQueue() Method
    The jQuery clearQueue() method removes all items from the queue that have not yet been run. Note that when a function has started to run, it runs until it is completed. Syntax: $(selector).clearQueue(name); Here "selector" is the selected element. Parameter: It accepts a parameter "name" which is th
    2 min read
  • jQuery delay() Method
    jQuery delay() method is an inbuilt that is used to set a timer to delay the execution of the next item in the queue.  Syntax:$(selector).delay(para1, para2);Parameter: It accepts two parameters which are specified below: para1: It specifies the speed of the delay.para2: It is optional and specifies
    2 min read
  • jQuery dequeue() Method
    The dequeue() method is an inbuilt method in jQuery that is used to remove the next function from the queue and then it will execute the function. In a queue there will be several functions waiting to run dequeue() used to remove the top function from the queue and execute that function. Syntax: $(s
    2 min read
  • jQuery fadeIn() Method
    The fadeIn() method in jQuery is used to change the opacity of selected elements from hidden to visible. The hidden elements will not be display. Syntax: $(selector).fadeIn( speed, easing, callback ) Parameters: This method accepts three parameters as mentioned above and described below: Speed: It i
    2 min read
  • jQuery Effect fadeOut() Method
    The fadeOut()Method in jQuery is used to change the level of opacity for selected element from visible to hidden. By using this method, the faded element will not occupy any space. Syntax: $(selector).fadeOut( speed, easing, callback ) Parameters: This method accepts three parameters as mentioned ab
    2 min read
  • jQuery fadeTo() Method
    The fadeTo() method is an inbuilt method in jQuery that is used to change the opacity of the selected element. Syntax: $(selector).fadeTo(speed, opacity, easing, call_function) Here selector is the selected element. Parameter: It accepts four parameters which are specified below- speed: It specifies
    2 min read
  • jQuery fadeToggle() Method
    The fadeToggle() Method in jQuery toggles between the fadeIn() and fadeOut() methods. If elements are faded in, fadeToggle() will fade out. If elements are faded out, fadeToggle() will fade in.  Syntax: $(selector).fadeToggle(speed, easing, callback)Parameters: This method accepts three parameters a
    2 min read
  • jQuery finish() Method
    The finish() is an inbuilt method in jQuery which is used to stop the animations running at the present time. Syntax: $(selector).finish(); Parameter: It does not accept any parameter. Return Value: It returns the selected element with its final values. jQuery code to show the working of finish() me
    1 min read
  • jQuery hide() Method
    The jQuery hide() method is used to hide selected HTML elements with a smooth animation effect. It reduces the element’s height to zero, effectively making it invisible. The method can also take a duration parameter to control the speed of the hiding animation. Syntax:$(element_selector).hide(durati
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences