【发布时间】:2020-05-15 08:23:17
【问题描述】:
我有这个(我知道这是错误的):
function copy() {
var copyText = document.getElementById("copy_");
copyText.select();
copyText.setSelectionRange(0, 99999)
document.execCommand("copy");
}
function copy2() {
var copyText2 = document.getElementById("copy_2");
copyText2.select();
copyText2.setSelectionRange(0, 99999)
document.execCommand("copy2");
}
它链接到这些:
<ol>
<li><p>Open Terminal and change directory to /test/:</p><input type="text" value="cd /Users/test/" id="copy_" disabled><button onclick="copy()">Copy</button></li>
<li><p>Make a directory:</p><input type="text" value="mkdir .test" id="copy_2" disabled><button onclick="copy2()">Copy</button></li>
</ol>
有人告诉我的一些同事使用事件对象和querySelectorAll,但我不确定如何合并它。
提前致谢
【问题讨论】:
标签: javascript function input copy