Addition of two numbers in jQuery
Here, Use this code for adding two numbers by using jquery. We create two input element in HTML and alert message will show the output.
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Adding two number in jQuery</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<meta charset="windows-1252">
<script>
$(document).ready(function () {
$("#submit").on("click", function () {
var a = parseInt($('#num1').val());
var b = parseInt($('#num2').val());
var sum = a + b;
alert(sum);
})
})
</script>
</head>
<body>
<input type="text" id="num1" name="option">
<input type="text" id="num2" name="task">
<input id="submit" type="button" value="Add Number">
</body>
</html>
Output