onfocusout event in Jquery

Date Published: 11/05/2020 Published By: JaiSchool

This event triggers when you focus on an element and then click anywhere else outside of that element. This works for input fields or any other element that has a contenteditable:true attribute.

Example~

<!DOCTYPE html>
<html>
<head>
  <title>Jquery on focusout event</title>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>



<h1 contenteditable="true" align="center">Click me and then click anywhere else.</h1>

<script>
 $(document).ready(function(){
   $("h1").on("focusout",function(){
      alert();
   });
});
</script>
</body>
</html>

Publish A Comment

Leave a Reply

Your email address will not be published. Required fields are marked *