Multiply Division Function is not Working when click on Multiply and Division Button

<div class="calculation">

    <form>

        <label>Enter 1st No.</label>

        <input type="number" id="firstNo">

        <label>Enter 2nd No.</label>

        <input type="number" id="secondNo">

    </form>

    <div class="myButton">

        <button class="btn-sm multiply">Myltiply</button>

        <button class="btn-sm division">Division</button>

    </div>

</div>

<script src="JavaPractice.js"></script>

document.querySelector(’.multiply’).addEventListener(‘click’, () => {

var firstNumber = document.getElementById('firstNo').value;

var secondNumber = document.getElementById('secondNo').value;

document.getElementById('firstNo').innerHTML = `Result is ${firstNumber*secondNumber}`;

});

document.querySelector(’.division’).addEventListener(‘click’, () => {

var firstNumber = document.getElementById('firstNo').value;

var secondNumber = document.getElementById('secondNo').value;

document.getElementById('secondNo').innerHTML = "Result is " + firstNumber / secondNumber;

});

Here’s a couple of things I will try and see what happens.

  1. Close the tag, either self-closing /> or separate
  2. Put a console.log inside the two event handling functions and check the values of firstNumber and secondNumber.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.