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

Javascript examples for DOM Event:onfocusout

Description

Using "onfocusout" together with the "onfocusin" 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  .ja v  a 2 s  . c om
    document.getElementById("myInput").style.background = "yellow";
}
function blurFunction() {
    document.getElementById("myInput").style.background = "red";
}
</script>

</body>
</html>

Related Tutorials