title: How to copy link which is declared in javaScript?
body: <p>Actually I want, I declare a link in javascript. And copy the link using a button.</p>
  <p>I'm trying this. But it's showing error.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
        $("#copy-button").click(function() {
          var copyLink = "https://stackoverflow.com/";
          copyLink .select();
          document.execCommand('copy');
        });
      });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>  body {
        padding: 20px;
      }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;script&gt;  src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt; &lt;link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" /&gt;
      &lt;button type="button" id="copy-button" class="btn btn-lg btn-primary btn-block"&gt; &lt;span class="fa fa-copy"&gt; &lt;/span&gt; Copy &lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>I'm trying this, but not work : <a href="https://stackoverflow.com/questions/57547210/copy-to-clipboard-with-rails-and-javascript-via-a-link">Copy to clipboard with Rails and Javascript via a link</a></p>