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

标签 javascript jquery printing

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

相关文章:

javascript - 在循环之后访问 for 循环计数器是否安全?

javascript - 将循环与 $.get 一起使用时如何获取循环外的数据

jquery - 简化 Jquery 代码 帮助!

jquery - 使用 jQuery 注释页面链接

r - 如何在 R 中创建不打印属性(不复制对象)的打印方法?

c# - 从表单打印面板时分辨率不佳

javascript - 使用 Javascript 或 jQuery 插入 Google Adwords 转化跟踪

javascript - Gridster - 保存 div 的 html 内容以动态加载网格

jquery - 使用 jQueryMobile 滑动时可滚动的 div

excel - 如何在宏中捕获菜单栏中的 "Print"按钮