Set Multiple Attributes

2 minutes
Share the link to this page
Copied
  Completed
Learn how to set not one but multiple attributes at one.

Transcript

Hello, in this jQuery video, I am going to show you how to set multiple attributes. So we got some code here which selects any, you know, div elements, but it could be any sort of selector modifies the attribute model for the title attribute and assign epic. But maybe you want to, you know, do multiple different attribute changes, instead of doing instead of duplicating it more than few times and changing the attribute value mean the attribute name and the value, you can do all using one function. And so let's just add an extra attribute. For the sake of it. Let's add in to Epic equals value.

Epic value. So if I reload, as you can see it appeared right here and to change multiple comment this All we'll just get rid of this model. As we need, what you'll need is a curly brace at the start. So right here you'll need a curly brace here as well. Okay, so here, instead of doing the name of the attribute, comma in the value, put the name of the attribute colon than the value then you put a comma. Now, this is a whole nother actually change the narrative.

Oh, and I'll change this to even better. Know one character though like Goku Yoda says that and I'll go back load ethnicity says hello world, and it says epic value. Before we click it. As you can see both attributes have changed even though there was only one single function right here. So that's how you set multiple attribute values. If you have any questions, feel free to call me a message.

And as usual, thanks for watching, and I look forward to seeing you in the next video.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.