

Programs in JavaScript
12. onFocus Event example.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function fun1()
{
document.getElementById("name").style.backgroundColor = "yellow"
}
function fun2()
{
document.getElementById("name").style.backgroundColor = "white"
}
</script>
</head>
<body>
Name : <input type="text" id="name" onfocus="fun1()" onchange="fun2()"/><input type="button" value="Hello" />
</body>
</html>
Output :Name :