+ 2
How can I make a backspace button for my calculator?
I'm making a simple calculator. I've made almost everything of the calculator. But I can't make a backspace button for my calculator. :( If anyone know any easy way then please tell... :) I made my reset button like this: function reset() { document.getElementById('display').value=""; } But I have no idea to make a backspace button.
2 odpowiedzi
+ 7
function backspace(){
var len=document.getElementById('display');
var inner=len.innerHTML;
len="";
inner=inner.split("");
inner=inner.splice(inner.length-1,1)
inner=inner.join("");
len.value=inner;
}
+ 2
since the value of your calculator is being stored as a string remove the last value in the string