Javascript Copy Function

Created Diff never expires
2 Entfernungen
Zeilen
Gesamt
Entfernt
Wörter
Gesamt
Entfernt
Um diese Funktion weiterhin zu nutzen, aktualisieren Sie auf
Diffchecker logo
Diffchecker Pro
15 Zeilen
2 Hinzufügungen
Zeilen
Gesamt
Hinzugefügt
Wörter
Gesamt
Hinzugefügt
Um diese Funktion weiterhin zu nutzen, aktualisieren Sie auf
Diffchecker logo
Diffchecker Pro
15 Zeilen
<body>
<body>
<h2 id="title">Copy to Clipboard - JavaScript - dcode</h2>
<h2 id="title">Copy to Clipboard - JavaScript - dcode</h2>
<input id="myInp" type="text">
<input id="myInp" type="text">
<button id="btnCopy">Copy</button>
<button id="btnCopy">Copy</button>
</body>
</body>
<script type="text/javascript">
<script type="text/javascript">
const myInp = document.getElementById("MyImp");
const myInp = document.getElementById("myInp");
const btnCopy = document.getElementById("btnCopy");
const btnCopy = document.getElementById("btnCopy");
btnCopy.onclick = function () {
btnCopy.onclick = function () {
// Step 1 - Select the text
// Step 1 - Select the text
myInp.select();
myInp.select();
// Step 2 - Copying the text
// Step 2 - Copying the text
document.execCommand("Copy");
document.execCommand("Copy");
};
};
<`/script>
</script>