【发布时间】:2021-04-01 09:41:56
【问题描述】:
function copyPaste(number) {
/* Get the text field */
var copyText = number;
/* Select the text field */
copyText.select();
copyText.setSelectionRange(0, 99999); /* For mobile devices */
/* Copy the text inside the text field */
document.execCommand("copy");
/* Alert the copied text */
alert("Copied the text: " + copyText);
}
<th><p id="phone" onclick="copyPaste(<?php echo $row['phone'];?>)"><?php echo $row['phone']; ?></p></th>
我在没有<p> 标签的情况下工作。它也不起作用..错误:来自控制台的Uncaught TypeError: copyText.select is not a function at copyPaste ((index):109) at HTMLParagraphElement.onclick。我在关注the course
【问题讨论】:
-
在该课程中,
copyText是一个元素 (document.getElementById("myInput")),而不是您要复制的文本 -
@brombeer 哦!是的……
-
@brombeer 我不知道该怎么做...你能帮忙吗?
标签: javascript html copy