復制代碼 代碼如下:
<!DOCTYPE html>
<html>
<body>
<p id="p1">這是一段文本。</p>
<input type="button" value="隱藏文本" onclick="document.getElementById('p1').style.visibility='hidden'" />
<input type="button" value="顯示文本" onclick="document.getElementById('p1').style.visibility='visible'" />
</body>
</html>