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.

Attributes and properties

Attributes and properties - jQuery Tutorial

From the course: jQuery for Web Designers

Start my 1-month free trial

Attributes and properties

- [Voiceover] In this movie, we're going to talk about attributes and properties. Two similar sides of a rather subtle coin. The first thing we're going to do is take a look at attributes. Now, these are HTML attributes, so for example, when you have a link, you set the href attribute to the place where you want the link to go. So if I inspect this by right-clicking, href is an attribute, title is an attribute, and so is class, and I can access all of these in jQuery using its attribute method. Let's switch over to the script file and start writing a little code. I've gotten you started here with a little submit handler for this form that stops it from actually submitting when you click the button. So we're going to log a few messages here. We'll start off by logging what the href attribute is for the first link on the page. So we'll say first link, and then we'll pass in another argument, which will be our jQuery selection. So if I want the first link on the page, I'll take the a…

Contents