Hello, in this jQuery video, I am going to show you how to remove HTML elements. So there's two methods for this says the Remove method and the empty method. The remove method removes the element that you selected, plus all its Child Elements, the empty just move the child. So Nat me up. So I'm gonna say I'm gonna say hello, world, hello world. And I am going to put I'm going to put one article more divs in here.
Remember what the content is a good one. I can look up my favorite do live mesh tools well. I had mashed potato fishing yesterday. Okay, so mashed potato. And if we want to, you know, just demonstrate this, I'm going to create a couple of buttons. So button, text them remove inside of it to have empty.
I'm gonna put the textbook, reload, see what we get at the moment didn't do anything. But if we just add some selectors for the buttons. So new button add one. Anyone as well empty Give me a second. Copy and paste this time. Okay, so to move it, we just select the element, it could be simple, like a day or an advance letter that doesn't move.
Same for empty instead of the new method, empty method so far reload, see what we get so forgot to elements. You can see we got this. Let's see, if we click the empty one. First. It removes all content. So you remove all content, including including any text that's not enclosed inside of inside of a novel.
You know, element puts all content inside of it. What am I gonna do to demonstrate this properly? Let's have a bit of a style Whoa, have a background color. Red, all apply white so it's easy to see. And now on the fly in of itself. Also this is the middle and also min height of reload.
So this is supposed to all days we don't want that we don't know what's gonna select this particular one. Don't say parent give. Yeah, this will be a lot better than what happened before reload it. Yeah, that's what we want. I click empty. As you can see this div still exists before we load and I click Remove that div is Now disappeared what what do you think will happen fucking empty then remove your stove just remove the dip to the My room's got content inside of it or not.
So, you can go a step further and only remove based on a certain filter. So for example, for example, I have a class of epic div now I have another div and honestly pizza awesome. And I am going to create one button, this will be removed. So the button to remove so we're only going to remove any divs that have the class of epic div If I copy this, I mean, this will copy this on, it's already in there. So you should move filter button. And you do dot remove, but then you put the filter.
So in this case, I'm gonna put dot. And it was like if I reload. So we got the reg div and we got the regular div. Okay, so to remove it, we removed that one, because this particular div did not have this class at all, you can actually apply for or, you know, multiple conditions. So it's a whether or not it has, you know, a particular one, you know, by using comma, but this is the similar principle as you know, you would do with selectors. Well, that's it simple stuff, if you have any questions, because because we've covered quite a lot of, you know, content in the app, feel free to pop me a message and as usual I look forward to seeing you in the next video.