0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

javascriptで表示と非表示

Posted at


<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>

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?