title: jQuery copy and paste using document.execCommand("copy") and ("paste")
body: <p>I have one dropdown upon selection of which I want to copy the value of that dropdown and paste in an input field below without using clt+v every time</p>
  
  <p>Here is the code what I tried:</p>
  
  <pre><code>$('body').append(`&lt;div id="selectDialog" title="Select Regex Type" style="text-align:center;display:none;"&gt;
            &lt;select id="listSelection"&gt;
              &lt;option value =""&gt;None&lt;/option&gt;
              &lt;option value ="[a-z]+"&gt;Single Digit Integers&lt;/option&gt;
              &lt;option value ="^[0-9]"&gt;Multi Digit Number&lt;/option&gt;
              &lt;option value ="/^-?[0-9]+\.?[0-9]*$/"&gt;Decimal Number&lt;/option&gt;
            &lt;/select&gt;
  
            &lt;div style="margin:10px"&gt;
                   &lt;button id="closeSelection" style="background- 
                                   color:#3B5E9E" &gt;save&lt;/button&gt;
            &lt;/div&gt;
  
   &lt;/div&gt;`);
  
  
  
  $(function () {
  
              $("#selectDialog").dialog({
                  autoOpen: false,
              });
  
  
              $('#changePattern').on("click", function () {
                  $("#selectDialog").dialog("open");
              });
  
  
              $("#listSelection")
                  .change(function () {
  
                      var s = $("#listSelection option:selected").val();
                      $("#changePattern").val(s);
                      $("#changePattern").attr("patternMask" , s);
                      $('#changePattern').select();
                       document.execCommand("copy");
                       $('#reg').select();
  
                  })
                  .trigger("change");
  
           $('#reg').select( function (){
  
           /*here I am trying to copy using document.texecCommand("copy");
  but unable to copy*/
           });
  
  
              $('#closeSelection').on("click", function () {
                  $("#selectDialog").dialog("close");
              });
  
      });
  
  });
  </code></pre>
  
  <p>on clicking input having an id changePattern , i am opening an dropdown from which i am populating another field with id =reg</p>
  
  <p>h i am saving a pattern to:</p>
  
  <pre><code>&lt;input id="changePattern" /&gt;
  &lt;input id="reg" /&gt;
  </code></pre>