title: Javascript copy input value
body: <p>Hello Guys I want to copy input value yeah on button click But nothing work. Please Help!!</p>
  
  <pre><code>&lt;script&gt;
    function copyToClipboard(element) {
      var $temp = $("&lt;input&gt;");
      $("body").append($temp);
      $temp.val($(element).text()).select();
      document.execCommand("copy");
      $temp.remove();
    }
  &lt;/script&gt;   
  
  &lt;input type="text" class="form-control" name="myvalue"  id="myvalue" value="YEAH" readonly  /&gt;
  
  &lt;button class="btn btn-primary btn-block" onclick="copyToClipboard('#myvalue')"&gt;Copy myvalue&lt;/button&gt;
  </code></pre>