function copyToClipboard(elementId, buttonId) { const element = document.getElementById(elementId); const button = document.getElementById(buttonId); navigator.clipboard.writeText(element.innerText) .then(() => { const originalText = button.innerText; button.innerText = 'Copied!'; setTimeout(() => { button.innerText = originalText; }, 2000); }) .catch(err => { console.error('Failed to copy:', err); button.innerText = 'Failed'; }); }