In jquery, you can use the css() method to modify the display attribute, the syntax "$(selector).css("display","attribute value")" or "$(selector).css({ "display":"Attribute value"})".
The operating environment of this tutorial: windows7 system, jquery3.6 version, Dell G3 computer.
In jquery, you can use the css() method to modify the display attribute. The css() method sets one or more style properties of the selected element.
Syntax:
$(selector).css("propertyname","value"); $(selector).css({"propertyname":"value"});
Example: Set the display attribute of the div element to none to hide the div element.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="js/jquery-3.6.0.min.js"></script> </script> <script> $(document).ready(function(){ $("button").click(function(){ $("div").css({"display":"none"}); }); }); </script> </head> <body> <div style="border: 1px solid red;">hello</div> <br> <button>点击按钮,修改display属性</button> </body> </html>
Recommended related video tutorials: jQuery Tutorial (Video)
The above is the detailed content of How to modify the display attribute in jquery. For more information, please follow other related articles on the PHP Chinese website!