gpt4 book ai didi

javascript - 如何提供打印引导表的选项?

转载 作者:行者123 更新时间:2023-12-03 05:43:07 25 4
gpt4 key购买 nike

我的问题很简单且有限,我想打印一个具有 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com