JSFiddle - React, Tailwind, and code Playground
by Nikhil krishnan
HTML
<pre id="myInput">
<span style="color:#97EDDC;">class </span>nikhil
{
<span style="color:#97EDDC;">public</span> <span style="color:#97EDDC;">static </span> <span style="color:#97EDDC;">void </span> main(String args[])
{
System.out.println("Hello World!!");
}
}
</pre>
<textarea name="" id="copy" cols="30" rows="10"></textarea>
<button id="button">Copy</button>
CSS
class nikhil
{
public static void main(String args[])
{
System.out.println("Hello World!!");
}
}
JavaScript
function copyFunction() {
const copyText = document.getElementById("myInput").textContent;
const textArea = document.getElementById('copy');
textArea.textContent = copyText;
textArea.select();
document.execCommand("copy");
}
document.getElementById('button').addEventListener('click', copyFunction);