아래 소스 실행시켜보세요.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
});
function copyClipboard() {
var $temp = $("<input>");
$("body").append($temp);
$temp.val($("#copycontent").val()).select();
document.execCommand("copy");
$temp.remove();
}
function copyClipboard2(selector) {
var $temp = $("<input>");
$("body").append($temp);
$temp.val($(selector).text()).select();
document.execCommand("copy");
$temp.remove();
}
</script>
</head>
<body>
<button onclick="copyClipboard()">복사하기</button>
<button onclick="copyClipboard2('#p2')">복사하기2</button>
<p id="p2">Click me too!</p>
<input type="hidden" id="copycontent" value="안녕하세요">
<br/><br/>
<input type="text" placeholder="Paste here for test" />
</body>
</html>
'jQuery' 카테고리의 다른 글
jquery 오늘 날짜 구하기 (0) | 2018.12.10 |
---|---|
jquery action, submit (0) | 2018.11.26 |
jquery HTML DOM 객체 존재 여부 체크 (0) | 2018.06.23 |
jquery 차트 그래프 플러그인 사이트 (0) | 2018.04.17 |
jquery id, name, class 접근 (0) | 2018.04.03 |