Below a simple code:
HTML
<button type="button" onclick="message()" id="c" value="C">C</button>
<button type="button" onclick="clear()">Clear</button>
<span id="messageid"></span>
Javascript
<script>
function message() {
document.getElementById("messageid").innerHTML = "Test";
}
function clear() {
document.getElementById("messageid").innerHTML = "";
}
</script>
When I click clear button, the message output by button "C" is not clearing. I thought this is a fairly straight forward method to just call the innerHTML = "" to clear but apparently it didn't work. What am I missing here?