Javascript examples for DOM Event:onblur
Using "onblur" together with the "onfocus" event
<!DOCTYPE html> <html> <body> Enter your name: <input type="text" id="myInput" onfocus="focusFunction()" onblur="blurFunction()"> <script> function focusFunction() {//from ww w .j a va2s.c o m // Focus = Changes the background color of input to yellow document.getElementById("myInput").style.background = "yellow"; } function blurFunction() { // No focus = Changes the background color of input to red document.getElementById("myInput").style.background = "red"; } </script> </body> </html>