Answers for "onclick copy to clipboard"


onclick add to clipboard

//U need to have a button with the id the same as its name because it is going to be sent to the clipborad.
/*Like this: */
<button onClick="SelfCopy("  id="1">1</button>
<button onClick="SelfCopy("  id="2">2</button>
<button onClick="SelfCopy("  id="3">3</button>

function SelfCopy(copyText)
      alert("You just copied this: (" + copyText + ").");
Posted by: Guest on April-24-2021

how to copy text in the clipboard in js

  <input type="text" value="Hello world"(Can be of your choice) id="myInput"(id is the name of the text, you can change it later)
<button onclick="Hello()">Copy Text</button>

  function Hello() {
  var copyText = document.getElementById('myInput');
  console.log('Copied Text')
Posted by: Guest on October-14-2020

copy to clipboard javascript

// Since Async Clipboard API is not supported for all browser!
function copyTextToClipboard(text) {
  var textArea = document.createElement("textarea");
  textArea.value = text

  try {
    var successful = document.execCommand('copy');
    var msg = successful ? 'successful' : 'unsuccessful';
    console.log('Copying text command was ' + msg);
  } catch (err) {
    console.log('Oops, unable to copy');

Posted by: Guest on May-20-2020

javascript copy to clipboard

var copyTextarea = document.getElementById("someTextAreaToCopy");; //select the text area
document.execCommand("copy"); //copy to clipboard
Posted by: Guest on July-22-2019

Code answers related to "onclick copy to clipboard"

Code answers related to "Javascript"

Browse Popular Code Answers by Language