The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Make A Button To Copy Text Onto The Clipboard

TL;DR
TODO: Pull subtitle into page object html_start_default_section html_end_default_section script_start_default_section script_end_default_section

Notes

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Make A Button To Copy Text Onto The Clipboard


-- tldr/

-- html/
-- show

<p id="content">
  lima <em>delta</em> november
</p>

<button id="copyButton">
  Copy Content
</button>

-- /html

-- script/
-- show

const copyContent = async () => {
  try {
    await navigator.clipboard.writeText(
      content.innerText
    )
    copyButton.innerHTML = "Copied!"
  } catch (err) {
    console.error("Could not copy to clipboard")
  }
}

document.addEventListener("DOMContentLoaded", () => {
  copyButton.addEventListener("click", copyContent)
})

-- /script


-- /tldr

-- notes

- I'm using _innerText__ instead of _innerHTML__
in the copy. Using _innerHTML__ put the tags 
themselves in the output when I posted into
a plain-text editor


-- ref
-- title: MDN: Navigator Clipboard
-- url: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard


-- ref
-- title: MDN: Navigator Clipboard API
-- url: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API


-- categories
-- HTML
-- JS 

-- metadata
-- date: 2022-03-14 23:10:14
-- id: 26p8miod
-- status: draft 
-- type: post
-- site: aws