21 lines
720 B
JavaScript
21 lines
720 B
JavaScript
const copyButton = document.querySelector('.copy-iban');
|
|
const status = document.querySelector('#copy-status');
|
|
|
|
copyButton?.addEventListener('click', async () => {
|
|
status.textContent = '';
|
|
|
|
try {
|
|
await navigator.clipboard.writeText(copyButton.dataset.iban);
|
|
status.textContent = 'Die IBAN wurde in die Zwischenablage kopiert.';
|
|
copyButton.title = 'IBAN kopiert';
|
|
} catch {
|
|
const range = document.createRange();
|
|
range.selectNodeContents(copyButton);
|
|
const selection = window.getSelection();
|
|
selection.removeAllRanges();
|
|
selection.addRange(range);
|
|
status.textContent = 'Bitte kopieren Sie die markierte IBAN.';
|
|
copyButton.title = 'Bitte die markierte IBAN kopieren';
|
|
}
|
|
});
|