js copy paragraph onclick

Solutions on MaxInterview for js copy paragraph onclick by the best coders in the world

showing results for - "js copy paragraph onclick"
Randolph
23 May 2016
1var copy = document.querySelectorAll(".copy"); 
2
3for (const copied of copy) { 
4  copied.onclick = function() { 
5    document.execCommand("copy"); 
6  };  
7  copied.addEventListener("copy", function(event) { 
8    event.preventDefault(); 
9    if (event.clipboardData) { 
10      event.clipboardData.setData("text/plain", copied.textContent);
11      console.log(event.clipboardData.getData("text"))
12    };
13  });
14};
Michela
24 Apr 2016
1const span = document.querySelector("span");
2
3span.onclick = function() {
4  document.execCommand("copy");
5}
6
7span.addEventListener("copy", function(event) {
8  event.preventDefault();
9  if (event.clipboardData) {
10    event.clipboardData.setData("text/plain", span.textContent);
11    console.log(event.clipboardData.getData("text"))
12  }
13});
queries leading to this page
copy text on click javascripthow to add click to copy in javascriptjavascript copy on clickjavascript copy link onclickjavascript copy text from paragraph on clickhtml div onclick copy textjs copy on click spancopy to onclickjs copy on clickonclick copy text of paragraph javascriptcopy onclick htmlhow to make a copy when click jsjavascript onclick copy to clipboardcopy on clicking javasciptcopy text on button click jshow to copy text onclick on textcopy html text on clickhow to copy text on click on a button in javascripthow can copy textcontent when click javascriptjs vanilla on click create a copy elementpaste javascript on clickjavascript button to copy textcopy a field text js onclickjs copy paragraph onclickcreate element copy onclickjs copy text on button clickhow to copy text from input through button click jscopy text onclickhow to create button when click content copy to clipboard in javascriptonclick event copy the textjavascript copy clicked element textjavascript copy html element when clickedclick text to copy javascriptbutton to copy text javascriptjs copy text on clickcopy text in one click javascriptonclick on anchor tag copy text to clipboard javascriptjavascript onclick copyonclick to copy texthtml copy text on clickcopy on click jshow to copy on click javascriptcopy text in onclick button in jsonclick copy the text inside paragraph javascriptcopy text on button click in javascriptjavascript copy button textjavascript copy text on clickcopy text onclick javascriptjavascript on click link copyclick to copy javascripthow to create copy and paste upon click javascriptcopy to clipboard javascript onclickhow to copy on click jshtml onclick copy textclick copy javascriptclick to copy element text javascriptjavascript click to copyonclick copy textcopy text on click jsonclick copy text javascripthow to add onclick to copy textjs click to copy texthtml button onclick copy textcopy on click javascriptcopy text js button pressjs copy paragraph onclick