<input type="text" id="display" disabled>
javascript:
var display = document.getElementById('display');
var buttons = document.querySelectorAll('.key')
var equals = document.querySelector('equals')
function numDisplay(num){
display.value += num;
if(num === 'c'){
display.value = '';
}
}
function ans(){
var x = display.value
x = eval(x);
display.value = x;
}
function root(){
var r = display.value
r = Math.sqrt(r);
display.value = r;
}
function remove(){
var displayVal = display.value;
displayVal= displayVal.slice(0, -1);
display.value = displayVal;
}
`
I have built a js calculator, and the only thing left to do is limit the number of digits displayed on the display to 10. What function, or attribute can i use to do that?
I have already tried the maxlength attribute. That doesn't work. It seems that the attribute is not being triggered at all.
I just want the text input field to display 10 characters instead of a never ending string of numbers.