27 Jan jQuery – Show an element
To show an HTML element, use the jQuery show() method. In the below example, we will show the <p> element. Let us see the example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script> <script> $(document).ready(function(){ $(".hideme").click(function(){ $("p").hide(); }); $(".showme").click(function(){ $("p").show(); }); }); </script> </head> <body> <h1>Demo Heading</h1> <h2 class="hideme">Hide Text</h2> <h2 class="showme">Show Text</h2> <p>This is demo text to play with.</p> </body> </html> |
Output
No Comments