by hdjrudni · 1y ago · 0 comments
``` fetch('/my-content').then(async res => { if(res.ok) { document.getElementById('my-element').innerHtml = await res.text(); } }) ```
Something like that. Doesn't get much easier. Gone are the days of browser inconsistencies, at least of you stick to "Baseline Widely available" APIs which is now prominently displayed on MDN.
<textarea id="userNotes"></textarea>
<button type="button" id="copyButton">Copy</button>
<script>
copyButton.addEventListener('click', () => {
navigator.clipboard.writeText(userNotes.value)
copyButton.innerText = 'Copied'
setTimeout(() => copyButton.innerText = 'Copy', 1000)
})
</script>You do have to call `getElementById` on a document. There can be many documents in a window.
function getId(v) {return document.getElementById(v)}
Dev tools allows $ $$, dunno, make a macro?
We must not defy the system!
const g = (x) => document.getElementById(x);