Skip to content

Instantly share code, notes, and snippets.

@AR-Student824
Last active November 22, 2021 01:38
Show Gist options
  • Save AR-Student824/baebc13139d48e22af6bb03a9d834996 to your computer and use it in GitHub Desktop.
Save AR-Student824/baebc13139d48e22af6bb03a9d834996 to your computer and use it in GitHub Desktop.
Copy content when codeblocks are clicked:HTML,JS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<code>console.log('hello!')</code>
<script src="https://underdot.vercel.app/underdot.js" type="text/javascript"></script>
<script>
document.querySelectorAll('code').forEach(x => {
x.title = "Click to copy text";
x.style.cursor = "pointer";
x.onclick = function () {
_c(x.innerText).then(() => {
alert('Copied to clipboard!');
})
}
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment