Copy to clipboard in Javascript having hidden input field
<p>I have a span which shows the name of the user like this and a hidden input box which contains username of the user. The input box sits right below the span on UI and has visibility hidden</p>

<pre><code>&lt;span&gt; My Name &lt;/span&gt;
&lt;input type = "text" class = "hidden" value = "MyUserName"&gt; 
</code></pre>

<p>What I want is when the user clicks on the visible span and presses Ctrl + C, I want the value of the input box to get copied on the clipboard. (MyUserName in this case). Is there any way I can do this in Javascript? </p>
