This my checkbox elements:
<input type="checkbox" name="colors" value="blue" /> Blue <br/>
<input type="checkbox" name="colors" value="green" /> Green<br/>
<input type="checkbox" name="colors" value="yellow" /> Yellow<br/>
How can i get the last value from this multiple checkbox, just clear JS because i have been studying JS and HTML just for 2 days. Thanks.
Use document.querySelectorAll
var checkboxes = document.querySelectorAll("input[name=colors]")
var lastCheckbox = checkboxes[checkboxes.length - 1];
var lastCheckboxValue = lastCheckbox.value;
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments