addEventListener("blur", myFunction); - Javascript DOM Event

Javascript examples for DOM Event:addEventListener

Introduction

The onblur event occurs when an object loses focus.

Summary

Bubbles No
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>
<input type="text" id="fname">

<script>
document.getElementById("fname").addEventListener("blur", myFunction);

function myFunction() {/*from   w  w w. j a  va2  s.c  om*/
    console.log("Input field lost focus.");
}
</script>

</body>
</html>

Related Tutorials