Page 280 - Web Applications (803) Class 12
P. 280
12. Write JavaScript code so that when the user clicks inside the input box to enter text, the focus event is triggered
which calls the changecolour() function. Through the function, the background colour of the textbox changes to
aqua.
Ans. <html>
<script>
function changecolour()
{
document.getElementById(“input1”).style.background=”aqua”;
}
</script>
<body>
<h2> Enter text in the textbox and see the colour change!</h2>
<input type=”text” id=”input1” onfocus=”changecolour()”>
</body>
</html>
Output:
13. Write JavaScript code to display all even numbers from 40 to 60.
Ans. <html>
<head>
<title>Even Numbers</title>
</head>
<body text=blue>
<h1>Even Numbers from 40 to 60</h1>
<script>
278 Touchpad Web Applications-XII

