1
I have a discount coupon for my website, when clicking on the button it is copied. But I would like after copied to show a small balloon shaped pop-up saying "copied".
Follows my code:
let copiarTexto = () => {
//O texto que será copiado
const texto = "10KITS239";
//Cria um elemento input (pode ser um textarea)
let inputTest = document.createElement("input");
inputTest.value = texto;
//Anexa o elemento ao body
document.body.appendChild(inputTest);
//seleciona todo o texto do elemento
inputTest.select();
//executa o comando copy
//aqui é feito o ato de copiar para a area de trabalho com base na seleção
document.execCommand('copy');
//remove o elemento
document.body.removeChild(inputTest);
};
.banner-cupom img{
display: block;
padding: 10%;
margin-top: -70%;
}
.text-coupon {
font-size: 1.3em;
margin-top: -30%;
color: white;
margin-bottom: 20%;
text-align: center;
font-weight: bold;
}
.button, button {
display: -webkit-inline-box;
color: #fff;
border: 1px solid #72dafb;
border-radius: 10px;
margin-bottom: 10px;
text-align: center;
outline: 0;
background: #72dafb;
font-weight: bold;
padding-left: 2em;
padding-right: 2em;
}
.button:hover, button:hover {
cursor: pointer;
color: #fff;
background-color: #f6bc70;
border-color: #f6bc70;
text-decoration: none;
}
<div class="banner-cupom">
<img src="{{media url="wysiwyg/Paginas/kitbody/cupom_1.png"}}" alt="" />
<div class="text-coupon"> <button onclick="copiarTexto()">10KITS239</button>
</div>
</div>
Hello JVEUZEBIO, I managed to help you with your problem?
– RXSD