<script>
function findNumber(){
var num1 = parseInt(document.getElementById('txt1').value);
var num2 = parseInt(document.getElementById('txt2').value);
document.getElementById('large').innerHTML = num1>num2 ? num1 : num2;
document.getElementById('small').innerHTML = num1<num2 ? num1 : num2;
}
</script>
<body>
<input id="txt1" autofocus/>
<input id="txt2"/>
<button onclick="findNumber()"> Do </button>
<p>Largest is <span id="large"></span></p>
<p>Smallest is <span id="small"></span></p>
</body>
Largest is function findNumber(){
var num1 = parseInt(document.getElementById('txt1').value);
var num2 = parseInt(document.getElementById('txt2').value);
document.getElementById('large').innerHTML = num1>num2 ? num1 : num2;
document.getElementById('small').innerHTML = num1<num2 ? num1 : num2;
}
</script>
<body>
<input id="txt1" autofocus/>
<input id="txt2"/>
<button onclick="findNumber()"> Do </button>
<p>Largest is <span id="large"></span></p>
<p>Smallest is <span id="small"></span></p>
</body>
Demo
Smallest is
0 comments:
Post a Comment