我的应用程序中有一个可共享的链接,我想一键选择它,以便用户复制它。
我怎样才能以浏览器原生的方式实现它?
(现阶段我对 javascript 解决方案不感兴趣)
是否有我可以使用的 HTML5 属性?
有我可以使用的 CSS 东西吗?
最佳答案
这可能是您想要的?单击,这将被完全选中!见 fiddle :JSFiddle
#link {
user-select: all;
}
<div id="link">
i am some extra long example text i am some extra long example text i am some extra long example text i am some extra long example text
</div>
请注意 - 您需要以这种方式为其他浏览器实现此功能:
- Mozilla:
-moz-user-select: all;
- WebKit(Safari 除外):
-webkit-user-select: all;
- 微软:
-ms-user-select: element;
在这里阅读更多:user-select
关于html - 一键选择全文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58405313/