Code
Execute
<!DOCTYPE html> <html> <head> <title>Wikitechy onfocus attribute</title> </head> <body> <h2>Welcome to Wikitechy</h2> <p>Enter Your Name:</p> <input type="text" onfocus="onFocus(this)"> <script> function onFocus(obj) { obj.style.background = "orange"; } </script> </body> </html>
Result