小编Fab*_*nes的帖子

点击 - 复制到剪贴板

<p id="p1"> 
...here is a lot of text (html) mixed with php...
</p>
<button onclick="copyToClipboard('#p1')">Copy to clipboard</button>
------
JS

function copyToClipboard(element) {
  var $temp = $("<input>");
  $("body").append($temp);
  $temp.val($(element).text()).select();
  document.execCommand("copy");
  $temp.remove();
}
Run Code Online (Sandbox Code Playgroud)

当我单击按钮时,结果将被复制但没有粗体,下划线,行和其他格式化的东西.我如何复制它,因为它默认显示?

html jquery

5
推荐指数
1
解决办法
3719
查看次数

标签 统计

html ×1

jquery ×1