Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Callback Functions in JavaScript!

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
In this video, we'll use event handlers for the focus and blur events.
DOM and Event Listeners
element.addEventListener(eventType, callback);
eventType
could be a keyboard key press or a mouse event—like a mouse click. 'focus'
is the event when the cursor appears in a text input or text area, and when the form control loses 'focus'
, the 'blur'
event is triggered.
An event callback looks like this:
function (event) {
// Do something
}
Or...
event => {
// Do something
}
The event
object has a type
property for the type of event that triggered the callback and a target
property for the element from the event
object.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
Alex Hort-Francis
17,074 Points0 Answers
-
Kasoma Ibrahim
Full Stack JavaScript Techdegree Graduate 25,206 Points1 Answer
-
Tashan Duncan
Front End Web Development Techdegree Graduate 17,799 Points1 Answer
-
Christopher Evans
9,896 Points1 Answer
-
Aakash Srivastav
Full Stack JavaScript Techdegree Student 11,638 Points1 Answer
-
Brian Anstett
5,831 PointsFunction declaration for callback instead of an arrow function.
Posted by Brian AnstettBrian Anstett
5,831 Points1 Answer
View all discussions for this video
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up