Need help with AC button functionality and deleting button I am currently working on creating a calculator from scratch using Jquery. However, I am facing difficulties getting the calculate function to work.
Despite my attempts at experimenting with javascript and jquery while learning event handlers, I have not been successful in making it work.
function removeNumbers() {
$(".current-operand").innerHTML = ' ';
}
$(document).ready(init);
function init() {
$(".data-number").click(passInt);
$(".data-allclear").click(removeNumbers);
}
function passInt() {
$('.current-operand').append(parseInt($(this).html()));
}
<div class="calculator-grid">
<div class="output">
<div class="previous-operand "></div>
<div class="current-operand">0</div>
</div>
<button class="span-two data-allclear">AC</button>
<button class="data-delete">DEL</button>
<button class="data-operation">+</button>
<button class="data-number">1</button>
<button class="data-number">2</button>
<button class="data-number">3</button>
<button class="data-operation">*</button>
<button class="data-number">4</button>
<button class="data-number">5</button>
<button class="data-number">6</button>
<button class="data-operation">+</button>
<button class="data-number">7</button>
<button class="data-number">8</button>
<button class="data-number">9</button>
<button class="data-operation">-</button>
<button class="data-number">.</button>
<button class="data-number">0</button>
<button class="span-two data-equals">=</button>
</div>
</main>
Clicking on buttons with the class "data-number" should trigger an alert. My aim is for these numbers to display on the screen.