• JAVASCRIPT > copier dans le presse-papier

      HTML :

       

      <textarea id="monContenu">Des trucs à copier</textarea>
      
      <button id="monBouton" type="button">Copier</button>

       

      JAVASCRIPT :

       

      var toCopy  = document.getElementById( 'monContenu' ),
          btnCopy = document.getElementById( 'monBouton' );
      
      btnCopy.addEventListener( 'click', function(){
         toCopy.select();
         document.execCommand('copy');
         return false;
      });

       

      JQUERY :

       

      $('#monBouton').on( 'click', function() {
         $('#monContenu').select();
         document.execCommand( 'copy' );
      });

 

Aucun commentaire

 

Laissez un commentaire