1. First of all create input type text add attribute readonly="readonly" to it
2.Get that input element by id or whatever ex. x = document.getElementById("toCopy");
3. Add x.select(); function to select the text inside the input element
4. Call document function ex : document.execCommand("copy");
Here we go selected text at line number 3 will be copied
document.getElementById("toCopy");
<input readonly="readonly" style="font-size:15px;text-align:left;background:none;border:none;color:white;padding:10px;pointer:cursor;outline:none;width:100%;" id="toCopy" value="https://dropshare.in/3433gh">
document.getElementById("toCopy").select();
undefined
document.getElementById("toCopy").sele
undefined
document.getElementById("toCopy").select();
undefined
document.execCommand("copy");
true
No comments:
Post a Comment