1
I am a beginner in programming and I am developing a mini calculator project in order to study. I decided to implement a erase button to clean the display, but I can’t make it work at all.
HTML part of the display
<div class="visor">
<input type="text" name="display" id="display">
<input type="button" value="C" class='clear'id='clear' onclick="clear()">
</div>
part of the JS
function clear() { document.getElementById('display').value = ' '; }
i ultilized this same approach to write the number on the display and it works perfectly, but to delete no, how can I be solving this?
Take my +1 for having advised
<button type="reset">
.. That’s what he was invented for, you really have to use it!– fernandosavio
@fernandosavio was worth the young force, I think the only drawback of type reset is that you do not control which inputs it erases, if you have 10 input it erases everything... Same problem with CSS with Focus-Within, qq input that focus within the form already activates the class...
– hugocsl
The reset is from the form, so it’s supposed to be like this.. D
– fernandosavio