title: Copy to clipboard using jquery?
body: <p>I want to copy text to clipboard using jquery. But somewhere I am missing. I have the following codes:</p>
  
  <pre><code>&lt;span class="copy-btn" data-type="attribute" data-attr-name="data-clipboard-text" data-model="couponCode" data-clipboard-text="&lt;?php echo $result-&gt;coupon_code; ?&gt;"&gt;COPY CODE&lt;/span&gt;
                    &lt;/div&gt;
  </code></pre>
  
  <p>And jquery is as follows:</p>
  
  <pre><code>$(document).ready(function(){
      $('.copy-btn').on("click", function(){
          value = $(this).data('clipboard-text'); //Upto this I am getting value
          var $temp = $("&lt;input&gt;");
            $("body").append($temp);
            $temp.val($(value).text()).select();
            document.execCommand("copy");
            $temp.remove();
      })
  })
  </code></pre>
  
  <p>So please correct me, how can I copy code to clipboard. I am getting the value of the text, but after that I am unable to proceed.</p>