showing results for - "copy clipboard with span"
Lucas
22 Sep 2016
1document.getElementById("cp_btn").addEventListener("click", copy_password);
2
3function copy_password() {
4    var copyText = document.getElementById("pwd_spn");
5    var textArea = document.createElement("textarea");
6    textArea.value = copyText.textContent;
7    document.body.appendChild(textArea);
8    textArea.select();
9    document.execCommand("Copy");
10    textArea.remove();
11}
Hendrik
23 Nov 2018
1// Copy to clipboard on a click event
2document.querySelector("#copy-button").addEventListener('click', function() {
3	var reference_element = document.querySelector('#to-select-text');
4
5	var range = document.createRange();  
6	range.selectNodeContents(reference_element);
7
8	window.getSelection().addRange(range);
9
10	var success = document.execCommand('copy');
11	if(success)
12		console.log('Successfully copied to clipboard');
13	else
14		console.log('Unable to copy to clipboard');
15
16	window.getSelection().removeRange(range);
17});
18
Marilou
15 Jan 2016
1<span id="to-select-text">1111 - 2222 - 3333 - 4444</span>
2<button id="copy-button">Copy</button>
queries leading to this page
copy div innerhtml to clipboard javascriptcopy a text in jscpoy text to clipboard jsjs copy text from spancopy clipboard with spancopy text in jsjavascript copy text insidespan copy to clipboardcopy span text to clipboardcopy text to clipboard from p tag javascriptcopy text to clipboard javascript from inputon span click copy contentnodejs how to copy text to clipboardcopy to clipboard without input spanjs copy div content to clipboardclick to copy text javascripthow to copy text in clipboard javascriptcopy a span element to clipboard javascriptcopy text from clipboard javascripthtml copy from spancopy spanjavascript copy html element to clipboardcopy to clipboard span tag clipboard text in spanjs copy textcopy a value to clipboard with jscopy clipboard jsjs copy span to clipboardjavascript copy to clipboard from span elementcopy text jsjs copy to clipboard divjavascript copy innertext to clipboard line breakscopy text with javascriptcopy span to clipboardhow to add text to clipboard evnt javascriptcopy text from span javascriptjavascript copy as plain textcopy child text copy parent text in jscopied span on clickhow to copy text in span javascriptcode forr copy from span tag using javascriptcopy to clipboard in reactjscopy text using javascriptjavascript copy text to clipboard from spanjs copy span text to clipboardcopy text javascriptcopy text to clip board in jsjavascript copy text to clipboardcopy element to clipboard javascriptjavascript copy div to clipboardjavascript copy to clipboard selected textcopy text in javascriptjs copy text elementjavascript copy textcopy text to clipboard javascript without inputcopy div text to clipboardjavascript how to copy textcopy to clipboard from spancopy span text to clipboard jquerycopy div content to clipboard javascriptjavascript copy div content to clipboardcopy span value to clipboardjs click to copy textcopy text in element jsjs copy text to clipboardjavascript copy span to clipboardhow to copy text to the clipboard javascripthow to copy the text to the clipboard in javascriptjavascript copy div html content to clipboardcopy text to clipboard jsmake copy of spancopy clipboard with span examplehow to copy text to clipboard of tag p in javascriptcopy textarea in reactjshow to copy textcontent to clipboard in javascriptjavascript copy text to clipboard without inputjavascript copy span text to clipboardinsert text to clipboard jscopy span tag in cilipboardcopy div text to clipboard typescriptjavascript copy text in div to clipboardadd copy to clipboard fxnality in jscopy text from span to clipboardcopy text to clipboard javascriptjavascript copy text to clipboard without selecthtml copy to clipboard without javascripthow to put a spam with the text 22copy to clipboard 22 in jscopy span tag in cilipboard jscopy to clipboard with spacing jscopy clipboard with span