Develop
2018.04.05 09:57
[js] Click button copy to clipboard
조회 수 4400 댓글 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
-
[c] 연산자 우선순위.. ㅋㅋ
-
[c] 지폰(gphone) 소스.. 수정(암호화)
-
[asp] 기본 문법과 제어문
-
[c] 신기한 atoi함수(www.game79.net)
-
[c] 로또(Lotto) 번호 생성기
-
[linux] crond 사용법.. ㅋㅋ
-
[js] php의 number_format() 함수와 같은.. ㅋㅋ
-
[js] 한글문서로 된 259가지 자바스크립트 예제파일
-
[pdf] 포인터 문법 정리 (C pointer)
-
[linux] 임베디드 리눅스 (embedded linux)
-
[c] 게임 AI FSM 테스트 샘플 소스.. 꽤 괜찮은 소스..
-
[c] 문자열 라이브러리 최신버전