Answers for "create a button to copy url to clipboard js"

2

copy button value to clipboard function javascript

//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(this.id)"  id="1">1</button>
<button onClick="SelfCopy(this.id)"  id="2">2</button>
<button onClick="SelfCopy(this.id)"  id="3">3</button>

function SelfCopy(copyText)
  {
      navigator.clipboard.writeText(copyText);
      alert("You just copied this: (" + copyText + ").");
  }
Posted by: Guest on April-24-2021
0

how copy url of page to clipboard javascript

var $temp = $("<input>");
var $url = $(location).attr('href');

$('.clipboard').on('click', function() {
  $("body").append($temp);
  $temp.val($url).select();
  document.execCommand("copy");
  $temp.remove();
  $("p").text("URL copied!");
})
Posted by: Guest on December-13-2021

Code answers related to "create a button to copy url to clipboard js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language