多次呼叫API 會全部依順序跑完
$.ajaxSettings.async = true;
js 複製到剪貼簿
<button id="copy_c" style="float:right;margin-right:10px;">複製到剪貼簿</button>
$('body').off('click', '#copy_c');
$('body').on('click', '#copy_c', function () {
//var outputElement = document.getElementById('output_id');
copyTextFromElement('output_id');
});
//If you want to copyText from Element
function copyTextFromElement(elementID) {
let element = document.getElementById(elementID); //select the element
let elementText = element.textContent; //get the text content from the element
copyText(elementText); //use the copyText function below
}
//If you only want to put some Text in the Clipboard just use this function
// and pass the string to copied as the argument.
function copyText(text) {
var dummy = document.createElement('textarea');
document.body.appendChild(dummy);
//console.log(text);
dummy.value = text;
dummy.select();
document.execCommand('copy');
document.body.removeChild(dummy);
}