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.

       $("#txtBlur").blur(function () {
           alert("blur handler called");

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: 6605 | Post Order: 60

Write for us

Hosting Recommendations