JSFiddle - React, Tailwind, and code Playground

by rustyjeans

HTML

<ul>
  <li>Thing One</li>
  <li>Thing Two</li>
</ul>

JavaScript

function copyTextToClipboard(text) {
  var $input = $('<input value="' + text + '" />')
  .css({position: 'absolute', left: '-1000px'})
  .appendTo('body');
  $input.select();
  document.execCommand("copy");
  $input.remove();
}
$(function () {
  $('li').click(function() {
    var text = $(this).text();
    copyTextToClipboard(text);
  });
});