Did you find this useful?
Socialize it today.


jQuery Blur Event

Thursday, June 14, 2012

The jQuery event blur() method triggers when an element loses focus. The blur() method triggers the blur event, or it can specify a function to run when a blur event occurs. Originally, this event was only applicable to form elements, such as <input>. In modern browsers, the domain of the event has been extended to include all element types. An element can lose focus via keyboard commands or by mouse clicks elsewhere on the page.


Syntax

$(selector).blur()
$(selector).blur(function)


ParameterDescription
functionOptional. Function to run when the event occurs


Example


$("input").blur(function () {
    $("input").css("background-color", "#666666");
     });


In the jQuery code listed above, the blur() method specifies that a function should run when the blur event occurs. In the example below, the input element's background-color property will be changed when it loses focus. Click on the input element, type in some text, and click the TAB key or use your mouse to click somewhere else on the page.


First Name

Please help us spread the word by socializing it today!

email contact us

Did you find something wrong with the information on this page? Please take a moment to report it to us so that we can continue to improve the quality of the information on this site. Click here to report an issue with this page.



Recommended Books & Training Resources

JavaScript and jQuery: The Missing Manual HTML CSS and JavaScript Editor Pro jQuery