x0/modules/copy.js
2023-12-24 00:32:43 +01:00

10 lines
No EOL
401 B
JavaScript

// [x-copy-query="<query selector>"]
// [x-inner-text] - will use innerText
document.querySelectorAll("[x-copy-query]")
.forEach(e => {
if (e.hasAttribute("x-inner-text")) {
e.innerText = document.querySelector(e.getAttribute("x-copy-query")).innerHTML
} else {
e.innerHTML = document.querySelector(e.getAttribute("x-copy-query")).innerHTML
}
})