Step 1:Create index.html file and implement below code.
<p>If you click on the "Hide" button, I will disappear.</p> <button class="btn btn-success" id="hide">Hide</button> <button class="btn btn-success" id="show">Show</button>
Step 2:Implement jquery to do hide and show html element.
<script> $(document).ready(function(){ $("#hide").click(function(){ $("p").hide(); }); $("#show").click(function(){ $("p").show(); }); }); </script>
Complete Code For Hiding And Showing HTML Elements Using JQuery
<!DOCTYPE html> <html> <head> <title>How Can I Hide And Show HTML Elements Using JQuery</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <style> body { background: darkolivegreen; } </style> <body> <div class="container"> <br><br><br> <div class="text-center"> <h2 id="color" style="color: White">Hide And Show HTML Elements Using JQuery</h2> </div> <br> <br> <div class="well"> <p>If you click on the "Hide" button, I will disappear.</p> <button class="btn btn-success" id="hide">Hide</button> <button class="btn btn-success" id="show">Show</button> </div> </div> </body> </html> <script> $(document).ready(function(){ $("#hide").click(function(){ $("p").hide(); }); $("#show").click(function(){ $("p").show(); }); }); </script>