<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>隐藏和显示二维码的HTML代码</title>
</head>
<body>
<h1>隐藏和显示二维码的HTML代码</h1>
<p>本页面展示了如何在HTML中实现隐藏和显示二维码。以下是示例代码:</p>
<div id="qrcode" style="display:none">
<img src="https://www.example.com/qrcode.jpg"/>
</div>
<button onclick="toggleQRCode()">显示/隐藏二维码</button>
<script>
function toggleQRCode() {
var qrcodeDiv = document.getElementById("qrcode");
if (qrcodeDiv.style.display === 'none') {
qrcodeDiv.style.display = 'block';
} else {
qrcodeDiv.style.display = 'none';
}
}
</script>
</body>
</html>
暂无评论