Diff
checker
Text
Text
Images
Documents
Excel
Folders
Legal
Enterprise
Desktop
Pricing
Sign in
Download Diffchecker Desktop
Compare text
Find the difference between two text files
Tools
History
Real-time editor
Hide unchanged lines
Disable line wrap
Layout
Split
Unified
Diff precision
Smart
Word
Char
Syntax highlighting
Choose syntax
Ignore
Transform text
Go to first change
Edit input
Diffchecker Desktop
The most secure way to run Diffchecker. Get the Diffchecker Desktop app: your diffs never leave your computer!
Get Desktop
Javascript Copy Function
Created
6 years ago
Diff never expires
Clear
Export
Share
Explain
2 removals
Lines
Total
Removed
Characters
Total
Removed
To continue using this feature, upgrade to
Diff
checker
Pro
View Pricing
15 lines
Copy
1 addition
Lines
Total
Added
Characters
Total
Added
To continue using this feature, upgrade to
Diff
checker
Pro
View Pricing
15 lines
Copy
<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">
Copy
Copied
Copy
Copied
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");
};
};
Copy
Copied
Copy
Copied
<
`
/script>
<
/script>
Saved diffs
Original text
Open file
<body> <h2 id="title">Copy to Clipboard - JavaScript - dcode</h2> <input id="myInp" type="text"> <button id="btnCopy">Copy</button> </body> <script type="text/javascript"> const myInp = document.getElementById("MyImp"); const btnCopy = document.getElementById("btnCopy"); btnCopy.onclick = function () { // Step 1 - Select the text myInp.select(); // Step 2 - Copying the text document.execCommand("Copy"); }; <`/script>
Changed text
Open file
<body> <h2 id="title">Copy to Clipboard - JavaScript - dcode</h2> <input id="myInp" type="text"> <button id="btnCopy">Copy</button> </body> <script type="text/javascript"> const myInp = document.getElementById("myInp"); const btnCopy = document.getElementById("btnCopy"); btnCopy.onclick = function () { // Step 1 - Select the text myInp.select(); // Step 2 - Copying the text document.execCommand("Copy"); }; </script>
Find difference