I am trying to build a simple calculator with Javascript and Im having issues when clearing display content.
Can someone please have a look at my code and let me know why it is not working.
Why won't setting the display value to an empty string work. What am I doing wrong? Tank you guys.
function testing(button){
var x = button.value;
document.getElementById("display").innerHTML+=x;
}
function clear() {
document.getElementById("display").innerHTML = "";
}
<body>
<input type="button" id="one" value="1" onClick="testing(this)">
<input type="button" id="one" value="2" onClick="testing(this)">
<input type="button" id="one" value="3" onClick="testing(this)">
<input type="button" id="clear" value="clear" onClick="clear()">
<h1 id="display"></h1>
</body>