0
点赞
收藏
分享

微信扫一扫

js布尔值的 取反点击开-关

​​图片压缩​​

​​百亿站点​​

<style>
p{
width: 100px;
height: 100px;
display: none;
background: red;
}
</style>
<body>
<input type="button" value="提交" id="tj">
<p id="p"></p>
</body>
<script>
var btn = document.getElementById("tj");
var t = true;
btn.onclick = function dian() {
var p = document.getElementById("p");
if (t) {
p.style.display = "block";
} else {
p.style.display = "none";
}
t = !t;
}

</script>



举报

相关推荐

0 条评论