If I copy an html table manually, I can paste it into a Google Doc with the formatting preserved (it looks like a table).
How can I copy the contents programmaticall
Yes!
function copy() {
var target = document.getElementById('my-div');
var range, select;
if (document.createRange) {
range = document.createRange();
range.selectNode(target)
select = window.getSelection();
select.removeAllRanges();
select.addRange(range);
document.execCommand('copy');
select.removeAllRanges();
} else {
range = document.body.createTextRange();
range.moveToElementText(target);
range.select();
document.execCommand('copy');
}
}
Hello stackoverflow!))