Hello, in this jQuery video, I'm going to show you how to get and set the HTML contents of an element. So we've got this little, you know, text part here with that allow you to get the text so far. So if I click that, it gets the text of this div element. But what if, for example, in here I have let's say 500, a p tag, and maybe a bunch of other images, you know, whatever I want to say hello, world. Save that reload, as in the element, section it updated before to console Click, click me. Got a bunch of empty space icon, you got the text if you want to get the HTML itself.
To get it, it's simple. You please text me punched him out. You can obviously assign this to a variable After pack it into the console directly. And if I click it, as you can see, it gets the HDMI as well, the paragraph tag, if you want to modify the HTML, there is also very simple, you just do that. And maybe I'm going to say old time. Say you all save that reload.
And you'll see we get this notice in a context here, I click it, it's been changed. So it has been replaced with this HTML content. So the text function just allows you purely to get the text from it. If there's any other elements, you will not get that formatting, and allows you to set those values. The HTML, however, allows you to get nice The text but the exact HTML led in there, and also set more HTML in here, you could put an image. Actually, that's what I do as an extra task.
Right here, I'm going to apply an image instead of putting some sort of random bold tag. That's it. If you have any questions, feel free to form your message. And as usual, I look forward to seeing you in the next video.