Code has been added to clipboard!

jQuery .focusOut(): Add Event Handlers to the focusOut Event

Reading time 1 min
Published Jul 3, 2019
Updated Sep 30, 2019

jQuery focusOut: Main Tips

  • The jQuery .focusOut() is a shorthand for .on() with focusOut as the event parameter.
  • This method binds an event handler to a focusOut event, invoked when the specified element or its children in jQuery lose focus.

Usage of .focusOut()

A jQuery focusOut event fires when an element or its descendants in jQuery lose focus. The .focusOut() method adds an event handler to the focusOut event.

In the example below, you will see no changes as you select an input field. However, when you click somewhere else, the field loses focus and changes its color:

To specify a function to be run when the specified element or its children lose focus, use this syntax:

$("selector").focusout(function)

.focusOut() vs. .blur()

Beginners sometimes confuse jQuery focusOut and blur events, since both of them fire when an element in jQuery loses focus.

If the element has no descendants, there is actually no difference between the two events. However, if there are children elements and they lose focus, the focusOut event will fire, and blur will not.

Note: if you don't specify any parameters, the method will simply trigger the event.

Learn jQuery
Introduction
Selectors
Events
Event Methods
Download
Callback
Chaining
Get and Set
Add Element
Remove Element
Traverse
Parent
Children
Sibling Traverse
Filtering
jQuery AJAX
Effects
Show and Hide
Fade Effect
Slide Effect
Animate Effect
Manipulate CSS
Width and Height
.addClass()
.after()
.animate()
.append()
.appendTo()
.attr()
.before()
.bind() (deprecated)
.blur()
.change()
.click()
.clone()
.css()
.dblclick()
.delay()
.delegate() and .undelegate() (deprecated)
.detach()
.empty()
.end()
.error() (deprecated)
.fadeIn()
.fadeOut()
.fadeTo()
.fadeToggle()
.finish()
.focus()
.focusIn()
.focusOut()
.hasClass()
.height()
.hide()
.hover()
.html()
.innerHeight()
.innerWidth()
.insertAfter()
.insertBefore()
.keypress()
.keyup()
.live() and .die() (deprecated)
.load() (deprecated)
.mousedown()
.mouseenter()
.mouseleave()
.mousemove()
.mouseout()
.mouseover()
.mouseup()
.off()
.offset()
.offsetParent()
.on()
.one()
.outerHeight()
.outerWidth()
.position()
.prepend()
.prependTo()
.prop()
.proxy()
.queue()
.ready()
.remove()
.removeAttr()
.removeClass()
.removeProp()
.replaceAll()
.replaceWith()
.resize()
.scroll()
.scrollLeft()
.scrollTop()
.show()
.slideDown()
.slideToggle()
.slideUp()
.stop()
.submit()
.text()
.toggle()
.toggleClass()
.trigger()
.triggerHandler()
.unbind() (deprecated)
.unload() (deprecated)
.unwrap()
.val()
.width()
.wrap()
Event Properties
event.currentTarget
event.preventDefault()
event.relatedTarget
event.stopImmediatePropagation()
event.stopPropagation()
event.target
event.timeStamp
event.type
event.which
jQuery .find()
jQuery .keydown()
jQuery.noConflict()
pageY and pageX