Skip to content

Instantly share code, notes, and snippets.

@maagmirror
Created November 26, 2019 23:39
Show Gist options
  • Save maagmirror/6b3cea1584bf29101d51ba0646211bd2 to your computer and use it in GitHub Desktop.
Save maagmirror/6b3cea1584bf29101d51ba0646211bd2 to your computer and use it in GitHub Desktop.
$(document).ready(function(){
// si da click al botón
$("#btnsend").on("click" , function(){
copyandappend();
})
//si da enter
$("#inputuser").keydown(function (e)
{
if (e.keyCode == 13)
{
copyandappend();
}
});
function copyandappend () {
var userNumber = $("#inputuser").val();
var resultado = Math.floor(userNumber * 1.34);
$(".resultado > textarea").html(resultado);
let textarea = $(".copy");
textarea.select();
document.execCommand("copy");
$('#inputuser').val('');
$("#inputuser").select();
$('#lastresults tr:first').after("<tr><td>" + resultado + " USD</td></tr>");
console.log('copied to clipboard :v');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment