Created
January 27, 2019 17:57
-
-
Save gmelodie/7730e3c09f06404e96106571a9f33504 to your computer and use it in GitHub Desktop.
Hiding the buttons on tic-tac-toe game
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<script type="text/javascript"> | |
function getSelectedButton(form, name) { | |
let radios = form.elements[name]; | |
for (button in radios) { | |
if (button.checked) { | |
return button; | |
} | |
} | |
} | |
function computePlay() { | |
let selected = getSelectedButton(document.getElementById('board'), 'play'); | |
selected.style.visibility = "hidden"; | |
} | |
</script> | |
<h1> Tic-tac-toe </h1> | |
<form id='board'> | |
<input type="radio" name="play" id="11"> | |
<input type="radio" name="play" id="12"> | |
<input type="radio" name="play" id="13"> | |
<br> | |
<input type="radio" name="play" id="21"> | |
<input type="radio" name="play" id="22"> | |
<input type="radio" name="play" id="23"> | |
<br> | |
<input type="radio" name="play" id="31"> | |
<input type="radio" name="play" id="32"> | |
<input type="radio" name="play" id="33"> | |
<br> | |
<button onclick="computePlay()"> Play! </button> | |
</form> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment