Develop
2018.04.05 09:57
[js] Click button copy to clipboard
조회 수 1163 댓글 0
Example no jQuery.
# JAVASCRIPT
function copyToClipboard(elementId) { // Create a "hidden" input var aux = document.createElement("input"); // Assign it the value of the specified element aux.setAttribute("value", document.getElementById(elementId).innerHTML); // Append it to the body document.body.appendChild(aux); // Highlight its content aux.select(); // Copy the highlighted text document.execCommand("copy"); // Remove it from the body document.body.removeChild(aux); }
# HTML
<p id="p1">P1: I am paragraph 1</p> <p id="p2">P2: I am a second paragraph</p> <button onclick="copyToClipboard('p1')">Copy P1</button> <button onclick="copyToClipboard('p2')">Copy P2</button> <br/><br/><input type="text" placeholder="Paste here for test" />
[출처] https://stackoverflow.com/questions/22581345/click-button-copy-to-clipboard-using-jquery
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
35 | PPT | [ppt] 정보보호관리 발표내용 #2 | hooni | 2016.12.08 | 1056 |
34 | PPT | [ppt] 정보보호관리 발표내용 | hooni | 2016.11.30 | 1066 |
33 | PPT | [ppt] 보안경제학 발표자료 | hooni | 2016.11.11 | 5 |
32 | PPT | 삼성페이(Samsung Pay) 구조 | hooni | 2016.09.09 | 917 |
31 | PPT | [ppt] 전자금융보안론 발표/설치 자료 | hooni | 2016.05.03 | 1306 |
30 | PPT | [ppt] OCB기술개발팀 OJT 자료 | hooni | 2015.11.13 | 1145 |
29 | PPT | [ppt] Macro for board game 발표자료 (@Team Study 2013.01.18) 1 | hooni | 2015.07.22 | 1262 |
28 | PPT | [ppt] Information Security 발표 자료 (@Team Study 2012.11.15) | hooni | 2015.07.22 | 872 |
27 | PPT | [ppt] Equation Solving 발표 자료 (@AjaxUI랩 밋업데이 2012.02.28) | hooni | 2015.07.22 | 900 |
26 | PPT | [ppt] iOS 플라랩#03(2015.04.27) 발표 자료 | hooni | 2015.04.24 | 1057 |
25 | PPT | [ppt] iOS 플라랩#02(2015.03.19) 발표 자료 | hooni | 2015.04.24 | 898 |
24 | PPT | [ppt] iOS 플라랩#01(2015.02.26) 발표 자료 | hooni | 2015.02.25 | 721 |