- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I show and hide an HTML element using jQuery?
To hide and show an HTML element using jQuery, use the hide and show() methods. Here, the <p> element is hidden and shown on button click,
Example
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("#visible").click(function(){ $("p").show(); }); $("#hidden").click(function(){ $("p").hide(); }); }); </script> </head> <body> <p>This text will show on clicking "Show element" button, and hide on clicking "Hide element" button.</p> <button id="hidden">Hide element</button> <button id="visible">Show element</button> </body> </html>
- Related Articles
- How can I show and hide div on mouse click using jQuery?
- How animate(), hide and show elements using jQuery?
- How to show/hide div element depending multiple values using Bootstrap and jQuery?
- How can I select an element by tag name using jQuery?
- How can I select an element by its class name using jQuery?
- How can I select an element by its ID attribute using jQuery?
- How can I get the ID of an DOM element using jQuery?
- How can I alter the color of an HTML5 canvas element using jQuery?
- How to get HTML content of an element using jQuery?
- How to set HTML content of an element using jQuery?
- How to add display:none in an HTML element using jQuery?
- How can I select an element by name with jQuery?
- How can I select an element with multiple classes in jQuery?
- How to remove all the attributes of an HTML element using jQuery?
- How can I bind all events on a DOM element using jQuery?

Advertisements