A simple example of changing the selected state of a marquee with js code
- 2020-03-30 00:57:42
- OfStack
Today, there was a requirement to change the selected state of the marquee using js code. I didn't want to be direct
function doGender(gender) {
if (gender == " male ") {
gel("radionan").style.checked = "checked";
} else {
gel("radionv").style.checked = "checked";
}
}
function gel(id) {
return document.getElementById(id);
}
Once executed, no response...
Because we set checked="checked" in the radio tag; So make a conscious decision to assign "checked" to gel("radionv").stylid.checked and check it out online
In the original js code to check the menu to assign the checked value to true.
Continue with:
function doGender(gender) {
if (gender == " male ") {
gel("radionan").style.checked = true;
} else {
gel("radionv").style.checked = true;
}
}
Once the execution, still no response, a little bit confused... What went wrong??
Isn't it the style attribute??
Just gel("radionan") and click to see the checked property.
That's right!!
function doGender(gender) {
if (gender == " male ") {
gel("radionan").checked = true;
} else {
gel("radionv").checked = true;
}
}
And so it was...
This is the end!!