Last active
November 22, 2021 01:38
-
-
Save AR-Student824/baebc13139d48e22af6bb03a9d834996 to your computer and use it in GitHub Desktop.
Copy content when codeblocks are clicked:HTML,JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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