[ Web 관련 ]/jQuery
클립보드에 복사하는 clipboard.js 라이브러리
BIZLAB
2020. 8. 5. 11:38
twpower.github.io/81-use-clipboard.js-in-javascript
CDN
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.7.1/clipboard.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.7.1/clipboard.min.js"></script>
<input id="str" value="">
<button type="button" class="btn" data-clipboard-target="#str">Copy</button>
<script>
$(document).ready(function() {
var clipboard = new Clipboard('.btn');
clipboard.on('success', function(e) {
console.log(e);
});
clipboard.on('error', function(e) {
console.log(e);
});
}
function write(value){
$('#str').val(value);
}
</script>