I would like to copy the text stored in a specific code block in a list item to the clipboard when a user clicks a button. I've found various methods online that allow you to copy when you click something, but I want to be able to do all of this on the page if possible.
For example, I will have a list of items as follows:
Click this page.
Type this code:
<Code Sample>
I would like to have a button that copies the code for that specific line item.
I've had success copying text using the solution provided in this other Stackoverflow forum, but that doesn't work if I'm wanting to have a button click copy text OTHER than what is stored in the button.