複製文字到剪貼簿
var currentFocus = document.activeElement;
var textArea = document.createElement("textarea");
textArea.value = "123";
document.body.appendChild(textArea);
textArea.select();
document.execCommand("copy");
document.body.removeChild(textArea);
if (currentFocus) currentFocus.focus();
var textArea = document.createElement("textarea");
textArea.value = "123";
document.body.appendChild(textArea);
textArea.select();
document.execCommand("copy");
document.body.removeChild(textArea);
if (currentFocus) currentFocus.focus();
jquery
====
var $temp = $("<input>");
$("body").append($temp);
$temp.val($(element).text()).select();
document.execCommand("copy");
$temp.remove();
留言