Javascript Copy Function

Created Diff never expires
2 हटाए गए
लाइनें
कुल
हटाया गया
शब्द
कुल
हटाया गया
इस सुविधा का उपयोग जारी रखने के लिए, अपग्रेड करें
Diffchecker logo
Diffchecker Pro
15 लाइनें
2 जोड़े गए
लाइनें
कुल
जोड़ा गया
शब्द
कुल
जोड़ा गया
इस सुविधा का उपयोग जारी रखने के लिए, अपग्रेड करें
Diffchecker logo
Diffchecker Pro
15 लाइनें
<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>