Im trying to remove a Div from the DOM via an <a> tag nested within it.
I guess what I am looking for is the pure Javascript version of jQuery’s
$('div').remove()
Here’s the html set up
<div> <a href = "#" onClick = "w/e()">Click me to remove the parent div</a></div>
Thanks ahead of time. 😀
You could define this function
and use it as
Reference:
Node.parentNode,Node.removeChildFurther notes:
<button>instead of a link (<a>) for this kind of behaviour. A link has a distinct semantic meaning, it has to link somewhere. You can use CSS to style the button accordingly.