jQuery > Events

Blur event in jQuery

How to attach a blur event to a html element in jQuery?


To attach blur event to an element, blur() method can be used that fires when the element loses focus.

<script>
       $("#txtBlur").blur(function () {
           alert("blur handler called");
       });
  </script>

In the above code snippet, we first find the textbox whose id is "txtBlur" and attach blur event. When blur event executes, we have declared a function to fire in which we have shown "blur handler called" message in the JavaScript alert box.

 Views: 7239 | Post Order: 60



Write for us






Hosting Recommendations