Open Notepad and write the following Code !!
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>HTML Tutorial</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(document).ready(function () {
var a = parseInt($('#txt1').val(), 10);
var b = parseInt($('#txt2').val(), 10);
$("#submit").on("click", function () {
var sum = a + b;
alert(sum);
})
})
</script>
</head>
<body>
<h2>Addition of Two No in Jquery</h2>
<label text="Enter 1st No"></label>
<input type="text" id="txt1" name="option">
<input type="text" id="txt2" name="task">
<input id="submit" type="button" value="press me">
</body>
</html>
Output:
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>HTML Tutorial</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(document).ready(function () {
var a = parseInt($('#txt1').val(), 10);
var b = parseInt($('#txt2').val(), 10);
$("#submit").on("click", function () {
var sum = a + b;
alert(sum);
})
})
</script>
</head>
<body>
<h2>Addition of Two No in Jquery</h2>
<label text="Enter 1st No"></label>
<input type="text" id="txt1" name="option">
<input type="text" id="txt2" name="task">
<input id="submit" type="button" value="press me">
</body>
</html>
Output:
Comments
Post a Comment