<p id="p1">でも我慢する</p>
<input type="button" value="夜にお菓子たべたいな" onclick="clickBtn1()" />
<script>
//初期表示は非表示
document.getElementById("p1").style.display ="none";
function clickBtn1(){
const p1 = document.getElementById("p1");
if(p1.style.display=="block"){
// noneで非表示
p1.style.display ="none";
}else{
// blockで表示
p1.style.display ="block";
}
}
</script>
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
00