Not are clean to me what you are trying to do in e
function, but I build this example for help you:
var red = document.getElementById("colorRed")
, blue = document.getElementById("colorBlue");
//document.write(red);
function e(){
if(blue.checked == true){
document.write("You prefer Blue");
} else if (red.checked == true){
document.write("You prefer Red");
} else {
document.write("You prefer nothing");
}
}
<form>
What color do you prefer?<br>
<input type="radio" id="colorRed" >Red</input>
<input type="radio" id="colorBlue" >Blue</input>
</form>
<button onclick="e()">far</button>
5
solved Why is my code’s ‘e’ not defined?