Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery Change CSS display Property to none or block</title> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <style> #myDiv{ padding: 20px; background: #abb1b8; margin-top: 10px; } </style> <script> $(document).ready(function(){ // Set div display to none $(".hide-btn").click(function(){ $("#myDiv").css("display", "none"); }); // Set div display to block $(".show-btn").click(function(){ $("#myDiv").css("display", "block"); }); }); </script> </head> <body> <button type="button" class="hide-btn">Display none</button> <button type="button" class="show-btn">Display block</button> <div id="myDiv">#myDiv</div> </body> </html>