title: document.execCommand(“copy”) doesn't work while calling it from $(document).on("click") function
body: <p>This is my code</p>
  <pre><code>$(document).on('click', '.cpyButton', function (e){
       msg = $(this).attr('data-message');
       copyToClipboard(msg);
          
  });
  
  function copyToClipboard(text) {
    var $temp = $(&quot;&lt;input&gt;&quot;);
    $(&quot;body&quot;).append($temp);
    $temp.val(text).select();
    document.execCommand(&quot;copy&quot;);
    $temp.remove();
  }
  </code></pre>
  <p>This code is not working but If I call copyToClipboard function with normal click function , It is working fine</p>
  <p>Ex :</p>
  <pre><code>$('#saveDraft').on('click', function(e) {
      copyToClipboard(&quot;working&quot;);
  })
  </code></pre>
  <p>I have a problem while working with <strong>$(document)</strong></p>