mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-12 20:19:13 +00:00
16 lines
382 B
JavaScript
16 lines
382 B
JavaScript
|
|
function setCopyValue() {
|
||
|
|
document.querySelectorAll('.copy-button').forEach(copyButton => {
|
||
|
|
const pre = copyButton.closest('pre');
|
||
|
|
const code = pre?.querySelector('code');
|
||
|
|
|
||
|
|
if (code) {
|
||
|
|
copyButton.value = code.textContent;
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
// Set data for all copy buttons when the page loads
|
||
|
|
setCopyValue();
|
||
|
|
|
||
|
|
document.addEventListener('turbo:load', setCopyValue);
|