Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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>Advertisements