Forum

> > Off Topic > HTML Function?
Forums overviewOff Topic overviewLog in to reply

English HTML Function?

3 replies
To the start Previous 1 Next To the start

old HTML Function?

P_206
BANNED Off Offline

Quote
Hello , i want to add a html code for the input text
Function: When clicking on a button he copy a input text , I just want that code , Thanks
edited 1×, last 09.06.16 05:33:02 am

old Re: HTML Function?

GeoB99
Moderator Off Offline

Quote
HTML hasn't a reserved function to copy an input text so you must implement a basic JS (JavaScript) code script for this:
1
2
3
4
5
6
7
8
9
10
11
12
13
<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>
Though user ohaz's suggestion regarding clipboards.js is way more better.
To the start Previous 1 Next To the start
Log in to replyOff Topic overviewForums overview