I am trying to delete the div when I click on it, yet I am unsure of how to go about this. Any help would be greatly appreciated.
HTML
<div onclick="fadeOut(this)"></div>
JavaScript
function fadeOut(i) {
????
}
I am trying to delete the div when I click on it, yet I am unsure of how to go about this. Any help would be greatly appreciated.
HTML
<div onclick="fadeOut(this)"></div>
JavaScript
function fadeOut(i) {
????
}
You can use outerHTML its the inverse of innerHTML as in outerHTML pertains to only the element.
function fadeOut(i) {
i.outerHTML = ''; // deletes it from the DOM
}
And if you don't want to display it but keep it in the DOM
function fadeOut(i) {
i.style.display = 'none'; // hides the element
}