Created a JS function to add two numbers in index.js
function add(number1, number2) { var num1 = parseInt(number1); var num2 = parstInt(number2); var num3 = num1.num2; return num3; }Created a html page in Visual Studio
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<title></title>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.js">
</script>
<script src="index.js"> </script>
</head>
<body>
<h1> Adding two numbers </h1>
<input id="num1" placeholder="0" />
<input id="num2" placeholder="0" />
<button id="btnAdd" type="button"> Add</button>
<input id="total" placeholder="0" readonly />
<script type="text/javascript">
$('document').ready(function () {
$('#btnAdd').click(function () {
$('#total').val(add(num1, num2));
});
});
</script>
</body>
</html>
When we click on "Add" button, total should be displayed But nothing happens with this code
num1.num2? How do you setnum1andnum2when callingadd(num1, num2)inside the jQuery?