JS visibility的用法哪边有误呢?
发布网友
发布时间:2022-04-23 16:04
我来回答
共1个回答
热心网友
时间:2023-10-09 01:27
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script>
function fun1() {
var x = "";
for (var i = 0; i < 5; i++) {
x = x + "数字" + i + '<br />';
};
demo.innerHTML = x;
if (demo.style.visibility == 'visible') {
demo.style.visibility = 'hidden';
} else {
demo.style.visibility = 'visible';
}
}
</script>
</head>
<body>
<p id="demo"></p>
<input type="button" value="click" onclick="fun1()">
</body>
</html>追问为什麼x改成demo就可以呢? x不是等於demo吗?