Methods to delete the hidden attribute: 1. Use removeAttr() to delete the hidden attribute directly, with the syntax "element.removeAttr("hidden")"; 2. Use prop() to set the value of the hidden attribute to empty. Syntax "element.prop("hidden","")".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
HTML hidden attribute
The hidden attribute specifies that the element is hidden. Hidden elements will not be displayed.
If you add this attribute to an element, the element will be hidden.
Example:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body> <p>这是一段可见的段落。</p> <p hidden="hidden">这是一段被隐藏的段落,现在显示出来了。</p> <p>这是一段可见的段落。</p> </body> </html>
How to delete the hidden attribute in jquery
1. Use removeAttr() to delete the hidden attribute
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script src="js/jquery-1.10.2.min.js"></script> <script> $(function () { $("button").click(function () { $("p").removeAttr("hidden"); }) }) </script> </head> <body> <p>这是一段可见的段落。</p> <p hidden="hidden">这是一段被隐藏的段落,现在显示出来了。</p> <p>这是一段可见的段落。</p> <button>删除hidden属性</button> </body> </html>
##2. Use prop() to set the value of the hidden attribute to empty
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script src="js/jquery-1.10.2.min.js"></script> <script> $(function () { $("button").click(function () { $("p").prop("hidden",""); }) }) </script> </head> <body> <p>这是一段可见的段落。</p> <p hidden="hidden">这是一段被隐藏的段落,现在显示出来了。</p> <p>这是一段可见的段落。</p> <button>删除hidden属性</button> </body> </html>
jQuery video tutorial, web front-end video】
The above is the detailed content of How to delete hidden attribute in jquery. For more information, please follow other related articles on the PHP Chinese website!