Using "onfocusin" together with the "onfocusout" event: - Javascript DOM Event

Javascript examples for DOM Event:onfocusin

Description

Using "onfocusin" together with the "onfocusout" event:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

Enter your name: <input type="text" id="myInput" onfocusin="focusFunction()" onfocusout="blurFunction()">

<script>
function focusFunction() {/*  w  w w.  j  a v  a 2s .  co m*/
    document.getElementById("myInput").style.background = "yellow";
}

function blurFunction() {
    document.getElementById("myInput").style.background = "red";
}
</script>

</body>
</html>

Related Tutorials