🆕 blog! “A simple "copy this code" button in JavaScript” Next to all the code s...

@Edent@mastodon.social

🆕 blog! “A simple "copy this code" button in JavaScript”

Next to all the code samples on this blog is a little "copy" button. That makes it easier to grab any of the code I've shared.

The HTML and JS is delightfully simple:

<button
onclick="navigator.clipboard.writeText(
this.parentNode.getElementsByTagName('code')[0].textContent
);"
…

đź‘€ Read more: shkspr.mobi/blog/2026/08/a-sim
⸻
#HowTo #HTML #javascript