<DOCTYPE! html>
<head>
<meta charset="UTF-8">
<title>sample3</title>
</head>
<body>
<h2>google</h2>
<a id="google" href="https://google.co.jp" style="display: block;">google</a>
<button id='google1' type=submit onclick="chg(google,google1)">非表示</button>
<br>
<h2>yahoo</h2>
<a id="yahoo" href="https://yahoo.co.jp" style="display: block;">yahoo</a>
<button id='yahoo1' type=submit onclick="chg(yahoo,yahoo1)">非表示</button>
<br>
<h2>ibm</h2>
<a id="ibm" href="https://ibm.com" style="display: block;">ibm</a>
<button id='ibm1' type=submit onclick="chg(ibm,ibm1)">非表示</button>
<br>
<script>
function chg(id,zzz) {
element = id;
if (element.style.display == 'block') {
element.style.display = 'none';
zzz.innerHTML = "表示";
} else {
element.style.display = 'block';
zzz.innerHTML = "非表示";
}
}
</script>
</body>
</html>
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