How do I check whether a checkbox checked in javascript?
// find element
let chkAgree = document.getElementById("element_id");
if(chkAgree.checked){
// true: logic goes here
}
else{
// false: logic goes here
}
Demo: https://jsbin.com/gudebiriki/1/edit?html,output
-
CreatedJan 16, 2020
-
UpdatedNov 03, 2020
-
Views1,349
Related Articles
Check/Uncheck checkboxes when parent checkbox is checked/unchecked and vice-versa in Java Script
Set DropDownList value based on text/value in Java Script
Get selected text/value from DropDownList (or) Select in Java Script
Get selected index from DropDownList (or) Select in Java Script
How to validate number in Java Script
How to add or remove rows dynamically to HTML Table in Java Script
How to create HTML Table dynamically in Java Script
How to get or set value of a textbox in Java Script
How to get Key Codes in Java Script
How to replace string in Java Script?