Hello, in this jQuery video, I'm going to show you how to set an attribute with a callback function. So we've got this set attribute code where you have a selector do di t tr, and then what attribute view or modify the number value, but instead of having this what you do is get rid of this function has two parameters. First is and then next is we can call this a regional region, Regina. Okay, so all it is just the index of the selected, you know, element because you might have more than one or you might select more than one day, for example, for example, and what do you do if I return here and I just put up new title. No reload. And I'm gonna see it says hello words the title Click me, it says new title.
So I thinking what's the point of this? Why would we do this we're just returning this is because we're doing a bit more computation, maybe because you know, for example, console dot log, and I'm going to log out. And I'm also going to log out the original value. And I'm just going to comment this on there, get rid of this. Now, go back, reload. And if I would click it, because zero in hello world, so hello world is the original attribute of the element and zero is the index and let me show you so if I were to create This texting have to be the same.
If I reload, click click me face 01. So we get the indexes I've lost, maybe you want to do something with that, perhaps, you know, they are buttons and they take you to a particular page, for example, and the index matters. And there's one use case and no use cases, maybe you you know, want to do some competition in May. And you could do some other Kobe for dismay jack could do whatever you want to, or this this to alter the power of. Okay. Save that reload, go to element, save Hello, I click it.
It now shows 100. So it's the index which is zero because there's only one element with that title on the screen. So it's zero plus 100. So you can do some, you know, comp mutation between these curly braces, and whatever you turn is the value that is applied to this attribute. So that's how you have a callback function when setting an attribute. If you have any questions, feel free to pop me a message.
Antonio, Thank you watching I look forward to seeing you in the next video.