Bears___ Posted April 1, 2022 Share Posted April 1, 2022 It doesnt work, it only copys the last one. i have about 20 of them. <script> function myFunction() { /* Get the text field */ var copyText = document.getElementById("myInput1"); /* Select the text field */ copyText.select(); copyText.setSelectionRange(0, 99999); /* For mobile devices */ /* Copy the text inside the text field */ navigator.clipboard.writeText(copyText.value); /* Alert the copied text */ alert("Copied the text: " + copyText.value); } </script> Link to comment Share on other sites More sharing options...
Ingolme Posted April 1, 2022 Share Posted April 1, 2022 document.getElementById("myInput1"); only returns a single element. You need to change the ID in order to select a different element. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now