Develop
2018.04.05 09:57
[js] Click button copy to clipboard
조회 수 1160 댓글 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
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
11 | Database | [mysql] CPU 점유율이 높을 때 확인할 내용 | hooni | 2015.08.26 | 6627 |
10 | Database | [mysql] 쿼리 실행시 ERROR 1366 (HY000) : incorrect string value : for column 3 | hooni | 2017.03.30 | 8716 |
9 | Database | [mysql] 중복데이터 삭제하는 초간단 쿼리 | hooni | 2017.11.22 | 3402 |
8 | Database | [mysql] MySQL 한글 깨짐 현상 해결하기(UTF8) | hooni | 2017.12.01 | 5445 |
7 | Database | [mysql] ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. | hooni | 2017.12.15 | 1151 |
6 | Database | [mysql] MacOS에 MySQL 설치, 설정, 암호 재설정 | hooni | 2017.12.15 | 1442 |
5 | Database | SQL JOIN 정리 (Inner Join & Outer Join) | hooni | 2019.11.22 | 1816 |
4 | Database | [mysql] MySql DB/테이블 사이즈 확인을 위한 쿼리 | hooni | 2019.11.22 | 640 |
3 | Database | [mysql] MySQL 백업 및 복구 | hooni | 2019.11.22 | 801 |
2 | Database | [oracle] Oracle 사용자 추가 절차 | hooni | 2019.11.22 | 597 |
1 | Database | [mysql] MySQL 데이터베이스 추가 및 사용자 추가 | hooni | 2019.11.22 | 645 |