Page Loading...
Run
Break Lines
Result
<!DOCTYPE html> <html> <head> <style> /* Add styles here */ </style> </head> <body> <h2>Type something and click on the button:</h2> <div> <input type="text" id="target" placeholder="Type something..." > <button onclick="copyText()">Copy to clipboard</button> </div> <script> function copyText(){ const target = document.getElementById('target'); target.select(); target.setSelectionRange(0, 99999); /* For mobile devices */ document.execCommand('copy'); alert('Text copied'); } </script> </body> </html>