I have a html radio button, but I want to know how can I get a value from it. (I'm working on Electron)
Here is my Radio code
<label class="container">Ne plus afficher cette page au lancement.<input type="checkbox" unchecked="uncheck"><span class="checkmark"></span>
Basically I want to call a funtion if the box is checked.
for exemple
Function typeFunction(){
//load a window (Not sure if this is right
mainWindow.loadFile('index.html')
}
First, you need to remove that unchecked
tag its useless. Secondly, give a class to the checkbox for example " checkButton ". Lastly, you need to select the Item from the DOM.
const checkBtn = document.querySelector('.checkButton');
If you want to DO something when the checkbox is checked you just need to use the .checked property ->
if(checkBtn.checked) {
// do something
} else {
// do something else
}
Also use function
because if you are gonna use it with capital ,,F'' JS is gonna think this is a function constructor
.
Give ids to each choice.
id="choice1"
Then get the value by referring to the said id. choice1.value
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.