Javascript: Element Suicide

Hey there! I'm currently working on a CLI tool to deploy WordPress apps to DigitalOcean. Check it out! It's free and open source.

A short tip on js suicide. Suicide? Well.. I mean have an element remove itself. I came across this a while ago: a ‘read more’ link which should set the display property of an element to ‘block’ and remove itself completely from the DOM. Plain javascript, no frameworks. Here’s what I came to:


It doesn’t require an id, name or anything else. Furthermore it doesn’t even require its parent to have and id! This may be dumb, but I love it!

About the author

Konstantin Kovshenin

WordPress Core Contributor, ex-Automattician, public speaker and consultant, enjoying life in Moscow. I blog about tech, WordPress and DevOps.