title: how to copy multiple pre tag contents with same id to clipboard using javascript or jquery
body: <p>By using similar id's i want to copy to clipboard method without onclick of button.
  Is it possible to do this with only id/class?
  if possible can any one give me the solution for this method?
  i almost tried couple of ways to do this but it doesn't works.</p>
  
  <pre><code>  &lt;html&gt;
       &lt;script src="jquery-1.8.3.min.js"&gt;&lt;/script&gt;
     &lt;head&gt;
   &lt;style&gt;
     #tooltip{display: none;position: absolute;cursor: pointer;top:50px;border: solid 1px #eee;background-color:black;padding: 10px;z-index: 1000;color:white;}
   &lt;/style&gt;
   &lt;/head&gt;
   &lt;span id="mytext"&gt;This is Example1&lt;/span&gt;
   &lt;span id="mytext"&gt;This is Example2&lt;/span&gt;
      &lt;input id="copy_btn" type="button" value="copy"&gt;
   &lt;div id="tooltip"&gt;copied.&lt;/div&gt;
   &lt;script&gt;
     var copyBtn = document.querySelector('#copy_btn');
        copyBtn.addEventListener('click', function () {
      var urlField = document.querySelector('#mytext');
      var range = document.createRange();
      range.selectNode(urlField);
      window.getSelection().addRange(range);
      document.execCommand('copy');
      }, false);
    &lt;/script&gt;
  &lt;script&gt;
      $(document).ready(function() {
      $("#copy_btn").click(function(evt) {
          evt.preventDefault();
        $("#tooltip").show();
        $("#tooltip").hide(3000);
         });
       });
  &lt;/script&gt;
  </code></pre>