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