<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Copiar Código Pix</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin-top: 50px;
}
#pix-code {
margin-bottom: 20px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
width: 300px;
word-wrap: break-word;
background: #f9f9f9;
}
#copy-btn {
padding: 10px 20px;
background-color: #1e90ff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s;
}
#copy-btn:hover {
background-color: #0056b3;
}
#message {
margin-top: 20px;
font-size: 14px;
color: green;
visibility: hidden;
}
</style>
</head>
<body>
<div>
<div id="pix-code">1234567890987654321</div>
<button id="copy-btn">Copiar código Pix</button>
<div id="message">Código Pix copiado com sucesso!</div>
</div>
<script>
document.getElementById("copy-btn").addEventListener("click", function() {
// Seleciona o código Pix
const pixCode = document.getElementById("pix-code").innerText;
// Cria um elemento temporário para copiar o texto
const tempInput = document.createElement("textarea");
tempInput.value = pixCode;
document.body.appendChild(tempInput);
tempInput.select();
document.execCommand("copy");
document.body.removeChild(tempInput);
// Exibe a mensagem
const message = document.getElementById("message");
message.style.visibility = "visible";
// Oculta a mensagem após 3 segundos
setTimeout(() => {
message.style.visibility = "hidden";
}, 3000);
});
</script>
</body>
</html>