From the course: jQuery for Web Designers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Event binding

Event binding - jQuery Tutorial

From the course: jQuery for Web Designers

Start my 1-month free trial

Event binding

- [Voiceover] Over the course of the next several videos, we're going to look at a few topics that are much easier to work with in jQuery than they are in vanilla JavaScript. And we're going to start with handling events. We've seen how you can use jQuery to make changes to things, but the only way we've done it so far is when the page loads. It's pretty rare to work this way in the real world, usually we're reacting to things that happen after the page loads. And to do that, we need to tie in to events. So here on this Contact form, I'm collecting some information through a series of form controls, and I'm going to pay special attention for now to this Name field. Let's switch over to the script file and start writing some jQuery. So here's my script. jQuery comes out of the box with an easy-to-use event handler called .on. And all I need to do is select the element that I want to act on. In this case, I'm gonna use the name field, which I happen to know has the id name2. And then…

Contents