CSSのdisplayプロパティ、要素の表示または非表示

6151 ワード

<html>

<head>

<script type="text/javascript">

    function removeElement() {

        document.getElementById("p1").style.display = "none";

        document.getElementById("d1").style.display = "none";

    }

    function showElement() {

        document.getElementById("p1").style.display = "block";

        document.getElementById("d1").style.display = "block";

    }

</script>

</head>

<body>



<h1>This is a header</h1>

<div id="d1">xxxxxxxxxxxxxxxxxxxxxxxxxx</div>

<p id="p1">This is some text. This is some text. This is some text.

This is some text. This is some text. This is some text.

This is some text. This is some text. This is some text.</p>



<input type="button" onclick="removeElement()" value="Do not display paragraph" />

<input type="button" onclick="showElement()" value="display paragraph" />

</body>

</html>