Removes the focus from the current element, and fires the onblur event.
The blur method has no effect on an element that is not the active element in the document. If you use the blur method for the active element, then it loses the active state (and of course the focus, too), and fires the onblur event. Note: the onbeforedeactivate, ondeactivate, onfocusout and DOMFocusOut events are also fired. In that case, the body element becomes the active element.
The blur method behaves differently on the window object in different browsers. If the browser window is the foreground window and the window.blur method is called:If you need the active element in the document, use the activeElement property. If you need to simulate other events, see the pages for the dispatchEvent and fireEvent methods.
- in Internet Explorer, the operating system activates another application window
- in Firefox, Google Chrome and Safari, the browser window only loses the active state when another Firefox, Google Chrome or Safari application can be activated
- in Opera, the blur method has no effect for windows.
You can find the related objects in the Supported by objects section below.
This method has no return value.
Example HTML code 1:
This example illustrates the use of the blur method.
Did you find this example helpful?
User Contributed Comments