Develop
2018.04.05 09:57
[js] Click button copy to clipboard
조회 수 4403 댓글 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
-
Aspect Oriented Programming in Objective-C
-
[c#] 툴바 소스.. 개인적으로 만드는거..
-
[ios] 배경에 Gradient 적용하기 (CAGradientLayer)
-
[ios] APNS, Remote Push 사용자가 수신을 동의했는지 확인하기
-
[ios] GMT Date와 Local Date 변환하기
-
[ios] Objective-C 에서 자주 사용하는 수학 함수와 유용한 Define
-
[ios] 카테고리 확장 메소드를 찾지 못하는 경우
-
[js] 문자열에서 숫자만 걸러내기 (jQuery 안쓰고 정규표현식)
-
[java] netty (비동기 이벤트 방식 네트워크 프레임워크) 사용법 #2 (client)
-
[android] SQLiteOpenHelper를 이용한 DBManager
-
[ios] 설정에서 푸시 알림(APNS) on/off 상태 확인
-
[python][django] request.cookie 읽어오기 ㅋㅋㅋ (쓰기)