JSFiddle - React, Tailwind, and code Playground

by Sergei Sokolov

HTML

<label for="in-a">Число A<input type="text" id="in-a"></label>
<label for="in-b">Число B<input type="text" id="in-b"></label>
<div id="sum"></div>

JavaScript

/**
 * для вопроса https://toster.ru/q/645919
 * Сложение двух чисел без задействия кнопок, как?
 */
const inA = document.getElementById("in-a");
const inB = document.getElementById("in-b");
const sum = document.getElementById("sum");
const update = () => sum.innerText = parseFloat(inA.value || 0) + parseFloat(inB.value || 0);
[inA, inB].forEach(el => el.addEventListener("input", update));