mirror of
https://github.com/ivabus/www
synced 2024-11-22 18:35:06 +03:00
Fixed JS with click-to-copy button
This commit is contained in:
parent
02bcd657e7
commit
1742a382c8
1 changed files with 3 additions and 6 deletions
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
<!-- The button used to copy the text -->
|
<!-- The button used to copy the text -->
|
||||||
|
|
||||||
<button type="button" class="clipboard-copy" id="liveToastBtn" onclick="myFunction()">copy</button>
|
<button type="button" class="clipboard-copy" id="liveToastBtn" onclick="changeCopied()">copy</button>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
function myFunction() {
|
function changeCopied() {
|
||||||
// Get the text field
|
// Get the text field
|
||||||
var copyText = document.getElementById("myInput");
|
var copyText = document.getElementById("myInput");
|
||||||
|
|
||||||
|
@ -189,11 +189,8 @@
|
||||||
// Copy the text inside the text field
|
// Copy the text inside the text field
|
||||||
navigator.clipboard.writeText(copyText.value);
|
navigator.clipboard.writeText(copyText.value);
|
||||||
|
|
||||||
/* Alert the copied text
|
|
||||||
alert("Copied " + copyText.value + " to clipboard");*/
|
|
||||||
|
|
||||||
//Change button text to 'copied'
|
document.getElementById("liveToastBtn").innerHTML = "copied!";
|
||||||
document.getElementById("copy-icon").innerHTML = "copied!";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue