Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140676

checkbox not working with multiple checkbox onclick

$
0
0

`

function myFunction(){
  var checkBox = document.getElementById("myCheck");
  var text = document.getElementById("text");
  if (checkBox.checked == true){
    text.style.display = "block";
  } else {
    text.style.display = "none";
}}
Checkbox 1: <input type="checkbox" id="myCheck" onclick="myFunction()"><p id="text" style="display:none">Checkbox 1 is CHECKED!</p><br>
Checkbox 2: <input type="checkbox" id="myCheck" onclick="myFunction()"><p id="text" style="display:none">Checkbox 2 is CHECKED!</p>

`I want both check box should work after click one by one on it the result I get only checkbox 1 is working another not working


Viewing all articles
Browse latest Browse all 140676

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>