04-04-2023, 07:56 AM
The HTML part between the <body></body> tags looks like this:
The JavaScript part looks like this:
Code:
Please enter a number here:
<br>
<input type="Text" id="Num1">
<br>
<input type="button" id="submit" value="submit" onclick="oddOrEven()"></input>
<p id="Output"></p>
<input type="button" id="reset" value="Reset" onclick="Reset()"></input>
The JavaScript part looks like this:
Code:
function oddOrEven()
{
Num1 = document.getElementById("Num1").value;
if(Num1 % 2 == 0)
{
document.getElementById("Output").innerHTML = "Even";
}
else
{
document.getElementById("Output").innerHTML = "Odd";
}
}
function Reset()
{
document.getElementById("Num1").value = "";
document.getElementById("Output").innerHTML = "";
}
Also follow me on Youtube for videos about video games:
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos