How to delete hidden attribute in jquery

青灯夜游
Release: 2022-04-27 18:56:16
Original
2903 people have browsed it

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","")".

How to delete hidden attribute in jquery

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>
Copy after login

How to delete hidden attribute in jquery

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>
Copy after login

How to delete hidden attribute in jquery

##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>
Copy after login

How to delete hidden attribute in jquery

[Recommended learning:

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!