Skip to content

Instantly share code, notes, and snippets.

@lamegaton
Created September 24, 2020 20:37
Show Gist options
  • Save lamegaton/f9bd7bd7d9969bfd8049985dec53df05 to your computer and use it in GitHub Desktop.
Save lamegaton/f9bd7bd7d9969bfd8049985dec53df05 to your computer and use it in GitHub Desktop.
Example of getElements
Tools
</br>
<label for="axe">axe</label>
<input type="checkbox" class="tools" name="tools" id="axe" value="axe"></br>
<label for="axe">bow</label>
<input type="checkbox" class="tools" name="tools" id="bow" value="bow">
var inputByName = document.getElementsByName("tools");
var inputByClass= document.getElementsByClassName("tools");
inputByClass[0].onclick = function(){
console.log(inputByClass[0].checked);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment