Workplace safety isn't just a checkbox – it's about real people. With 340 million workplace accidents happening each year, every missed safety precaution represents someone's well-being at stake.
Workplace safety isn't just a checkbox – it's about real people. With 340 million workplace accidents happening each year, every missed safety precaution represents someone's well-being at stake.
button.style.border = "none"; button.style.color = "gray"; button.style.position = "absolute"; button.style.top = "5px"; button.style.right = "10px"; // Copy only the content of the
element without the button text
button.addEventListener("click", function () {
button.remove(); // Temporarily remove button
// Copy the text inside
let code = codeBlock.innerText; // Get content from
navigator.clipboard.writeText(code).then(() => {
button.innerText = "Copied!";
setTimeout(() => (button.innerText = "Copy"), 2000);
}).catch(() => {
button.innerText = "Failed to Copy";
}).finally(() => {
// Restore the button
codeBlock.appendChild(button);
});
});
// Position the button in the code block
codeBlock.style.position = "relative";
codeBlock.appendChild(button);
});
});