我的问题很简单且有限,我想打印一个具有 Id (“myTbl”)的引导表,那么如何使用 javascript/jquery 使其成为可能?(我不想使用插件)
<小时/>我是使用 jquery 和 bootstrap 的新手,请帮忙
最佳答案
<script>
$(function () {
$('button[type="submit"]').click(function () {
var pageTitle = 'Page Title',
stylesheet = '//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css',
win = window.open('', 'Print', 'width=500,height=300');
win.document.write('<html><head><title>' + pageTitle + '</title>' +
'<link rel="stylesheet" href="' + stylesheet + '">' +
'</head><body>' + $('#myTbl')[0].outerHTML + '</body></html>');
win.document.close();
win.print();
win.close();
return false;
});
});
</script>
<button class="btn btn-default" type="submit">Print Item</button>
关于javascript - 如何提供打印引导表的选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40440434/