Categories
Post

Add a Button

Spread the love

A student asked how can I add a button when a button is clicked.

There are many more traditional (and arguably better) ways than this, but it would be tough to beat the brevity and speed here.

<button onclick="this.parentElement.innerHTML+=this.outerHTML">Me</button>

Click on the “me” button right here on this page.

or follow this link to a live editable code example.

https://replit.com/@kevinelong/button-clone

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.