Home > Web Front-end > Front-end Q&A > How to make checkbox invisible with JavaScript

How to make checkbox invisible with JavaScript

青灯夜游
Release: 2022-01-26 11:46:12
Original
1769 people have browsed it

Method: 1. Use a div element to wrap the check box; 2. Use "document.getElementById("id value")" to get the div element node; 3. Use "div element node.style. The display = "none";" statement makes the checkbox invisible.

How to make checkbox invisible with JavaScript

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

JavaScript makes the check box invisible

Make the check box invisible, that is, hide the check box.

When it comes to hidden elements, I think of using display:none, which requires adding this style to the element.

Implementation code:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
	</head>
	<body>
		<div id="box">
		     爱好:<input type="checkbox" name="running" id="run">跑步
		     <input type="checkbox" name="running" id="read">阅读
		     <input type="checkbox" name="running" id="shop">购物
		</div>
		<br />
		<button onclick="myFunction()">让复选框不可见</button>
		<script>
			function myFunction() {
				var box = document.getElementById("box");

				box.style.display = "none";
			}
		</script>
	</body>

</html>
Copy after login

How to make checkbox invisible with JavaScript

[Related recommendations: javascript learning tutorial]

The above is the detailed content of How to make checkbox invisible with JavaScript. 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