blur

< dom‎ | events
Jump to: navigation, search



Overview Table

Synchronous No
Bubbles No
Target dom/Element
Cancelable No
Default action

Examples

View live exampleThis example shows how to display the name of the object that has lost focus, that is, the object that fires the onblur event.

<html>
<body>
<input type="text" 
    name="txtFName" 
    value="First Name" 
    onblur="console.log(event.srcElement.name)">
<input type="text" 
    name="txtLName" 
    value="Last Name" 
    onblur="console.log(event.srcElement.name)">
<input type="text" 
    name="txtPhone" 
    value="Phone" 
    onblur="console.log(event.srcElement.name)">
</body>
</html>

Notes

Remarks

The onblur event fires on the original object before the onfocus or onclick event fires on the object that is receiving focus. Where applicable, the onblur event fires after the onchange event. Use the focus events to determine when to prepare an object to receive or validate input from the user. As of Microsoft Internet Explorer 5, you must set the tabIndex attribute of elements that expose the onblur event. For Internet Explorer 5 and later, the onblur event is asynchronous. Switches focus away from the object on which the event is fired. To invoke this event, do one of the following:

  • Click the mouse on the document background or another control.
  • Use the keyboard to navigate from one object to the next.
  • Invoke the blur method when an object has focus.
  • Switch focus to a different application or open a second window.

The pEvtObj parameter is required for the following interfaces:

  • HTMLAnchorEvents2
  • HTMLAreaEvents2
  • HTMLButtonElementEvents2
  • HTMLControlElementEvents2
  • HTMLDocumentEvents2
  • HTMLElementEvents2
  • HTMLFormElementEvents2
  • HTMLImgEvents2
  • HTMLFrameSiteEvents2
  • HTMLInputFileElementEvents2
  • HTMLInputImageEvents2
  • HTMLInputTextElementEvents2
  • HTMLLabelEvents2
  • HTMLLinkElementEvents2
  • HTMLMapEvents2
  • HTMLMarqueeElementEvents2
  • HTMLObjectElementEvents2
  • HTMLOptionButtonElementEvents2
  • HTMLScriptEvents2
  • HTMLSelectElementEvents2
  • HTMLStyleElementEvents2
  • HTMLTableEvents2
  • HTMLTextContainerEvents2
  • HTMLWindowEvents2
  • HTMLDocumentEvents4

Syntax

Standards information


Event handler parameters

pEvtObj [in]
Type: IHTMLEventObj

See also

Related pages (MSDN)

  • a
  • abbr
  • acronym
  • address
  • applet
  • area
  • audio
  • b
  • bdo
  • big
  • blockQuote
  • button
  • canvas
  • caption
  • center
  • cite
  • code
  • custom
  • dd
  • del
  • dfn
  • dir
  • div
  • dl
  • document
  • dt
  • em
  • embed
  • fieldSet
  • font
  • form
  • frame
  • frameSet
  • hn
  • hr
  • i
  • iframe
  • img
  • input type=button
  • input type=checkbox
  • input type=file
  • input type=image
  • input type=password
  • input type=radio
  • input type=reset
  • input type=submit
  • input type=text
  • ins
  • isIndex
  • kbd
  • label
  • legend
  • li
  • listing
  • marquee
  • media
  • menu
  • object
  • ol
  • option
  • p
  • plainText
  • pre
  • q
  • rt
  • ruby
  • s
  • samp
  • select
  • small
  • source
  • span
  • strike
  • strong
  • sub
  • sup
  • table
  • tBody
  • td
  • textArea
  • tFoot
  • th
  • tHead
  • tr
  • tt
  • u
  • ul
  • var
  • window
  • xmp
  • Reference
  • blur
  • focus
  • onfocusout

This article contains content originally from external sources.

Portions of this content come from the Microsoft Developer Network: [Windows Internet Explorer API reference Article]