onfocusin = myFunction(); - Javascript DOM Event

Javascript examples for DOM Event:Element Event Attribute

Description

The onfocusin event occurs when an element is about to get focus.

Summary

Bubbles Yes
Cancelable No
Supported HTML tags: ALL HTML elements, EXCEPT: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, and <title>

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

Enter your name: <input type="text" id="fname">

<script>
document.getElementById("fname").onfocusin = function() {myFunction()};

function myFunction() {/*w  w w . j  a v  a2 s .c  o m*/
    document.getElementById("fname").style.backgroundColor = "red";
}
</script>

</body>
</html>

Related Tutorials