- Code:
<input type="text"> <button>复制</button> <script> var input = document.getElementsByTagName('input')[0] var button = document.getElementsByTagName('button')[0] button.onclick = function(){ input.value = "hello world" input.select() document.execCommand("copy") } </script>
- Effect:
- Common methods of execCommand:
cut delete copy
Native js implements click copy function
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=324655187&siteId=291194637
Recommended
Ranking