Function: When clicking on a button he copy a input text , I just want that code , Thanks
edited 1×, last 09.06.16 03:33:02 am
HTML Function?
HTML Function?
1

<textarea id = "input">Some text to copy.</textarea>
<button id = "copy-button">Copy</button>
<script type = "text/javascript">
var input = document.getElementById("input");
var button = document.getElementById("copy-button");
button.addEventListener("click", function (event) {
event.preventDefault();
input.select();
document.execCommand("copy");
});
</script>
ohaz's suggestion regarding clipboards.js is way more better.
1
