JSFiddle - React, Tailwind, and code Playground
by Pragnesh Chauhan
HTML
<input type="text" name="input1" id="input1" value="5">
<input type="text" name="input2" id="input2" value="">
<a href="javascript: void(0)" onClick="calc()">Calculate</a>
<input type="text" name="output" id="output" value="">
JavaScript
function calc(){
var textValue1 = document.getElementById('input1').value;
var textValue2 = document.getElementById('input2').value;
if($.trim(textValue1) != '' && $.trim(textValue2) != ''){
document.getElementById('output').value = textValue1 * textValue2;
}
}
$(function(){
$('#input1').blur(calc);
$('#input2').blur(calc);
});