Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dantetesta/f28ac630416ffdfec29ae28b3fbf8d39 to your computer and use it in GitHub Desktop.
Save dantetesta/f28ac630416ffdfec29ae28b3fbf8d39 to your computer and use it in GitHub Desktop.
/*BY: ASK JARVIS + DANTE TESTA */
/*
Declare o #conteudo no campo a ser copiado
Declare o #copiar no botão que ao ser clicado vai copiar o conteúdo do campo #conteudo
*/
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script>
jQuery(document).ready(function(){
jQuery('.copiar').click(function(){
jQuery('.conteudo').select();
document.execCommand('copy');
jQuery(this).text('Copiado!');
jQuery(this).css('background-color','black');
jQuery(this).css('color','white');
setTimeout(function(){
jQuery('.copiar').text('Copiar');
jQuery('.copiar').css('background-color','#EF6909');
jQuery('.copiar').css('color','white');
},3000);
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment