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.
You do not need to call the blur method on the active element before you set the focus to another element, only use the focus or setActive method on that 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?
Supported by objects:
a, abbr, acronym, address, applet, area, b, bdo, big, blink, blockquote, body, button, caption, center, cite, code, col, colgroup, dd, del, dfn, dir, div, dl, dt, em, embed, fieldset, font, form, frame, frameset, h1, h2, h3, h4, h5, h6, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:image, input:password, input:radio, input:range, input:reset, input:search, input:submit, input:text, ins, isindex, kbd, keygen, label, legend, li, listing, map, marquee, menu, nobr, noframes, object, ol, option, p, plaintext, pre, q, rt, ruby, s, samp, select, small, span, strike, strong, sub, sup, table, tbody, td, textarea, tfoot, th, thead, tr, tt, u, ul, var, xmp
User Contributed Comments