Forum

> > Off Topic > HTML Function?
ForenübersichtOff Topic-ÜbersichtEinloggen, um zu antworten

Englisch HTML Function?

3 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt HTML Function?

P_206
BANNED Off Offline

Zitieren
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
1× editiert, zuletzt 09.06.16 05:33:02

alt Re: HTML Function?

GeoB99
Moderator Off Offline

Zitieren
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.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antwortenOff Topic-ÜbersichtForenübersicht