Google News
logo
JavaScript - Interview Questions
Which event triggers in JavaScript when an object loses focus?
The blur event triggers when object loses focus. An example here displays that we write a name in the textbox and then when the object loses focus, the text color is changed. This happens since the blur event triggers when the focus ends: 
 
<!DOCTYPE html>
<html>
  <body>
  <h2>Testing</h2>
  <input type="text" onblur="display(this)">
    <script>
         function display(z) {
         z.style.color = "green";
       }
    </script>
  </body>
</html> 
Advertisement