javascript - 我想在打印时隐藏数据表 Excel 按钮

标签 javascript php jquery codeigniter media-queries

我想在打印页面中隐藏 excel 数据表按钮。

  <style type="text/css" media="screen"> 
       @media print {
             .buttons-excel {
                display: none;
            }
          }
      </style>

<section class="content">
        <div class="row">
         <div class="table-responsive">
           <table id="loading_sheet_table" class="table table-bordered  table-sm" style=" overflow: auto;">
          </table>
       </div>
     </div>
    </section>


<script>
   $(document).ready(function() {
  $('#loading_sheet_table').DataTable( {
    "paging": false,
      dom: 'Bfrtip',
      buttons: [
          'excel'
      ]
  } );
} );  

   function printContent(e1) {
   event.preventDefault();
        var allVals = [];
      $('input[name=selectedrecord]:not(:checked').each(function() {
         allVals.push($(this).val());
         });
           allVals.forEach(function(i){
          $('tr').each(function(){
          $(this).find('td, th').eq(i-1).css({
                     display:'none'
         });
      });
    });

    $('#print').css('visibility', 'hidden'); //hiding print button on print page
    $('input[name=selectedrecord]').css('visibility', 'hidden'); //hiding Check box on print page
    var restorepage     = document.innterHTML;
    var printContent    = document.getElementById(e1).innterHTML;
    document.innterHTML = printContent;
    window.print();
    document.location.href = "<?php echo base_url(); ?>"; 
    location.href="<?php echo base_url(); ?>booking/report/loading_sheet/LoadingSheetController/loadingSheetPage", 'refresh';
     }
</script>

我使用@media Print作为隐藏按钮,但它不起作用。

最佳答案

删除或修改媒体属性

<style type="text/css" media="print">

关于javascript - 我想在打印时隐藏数据表 Excel 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57567621/

相关文章:

javascript - 是否可以创建一个 promise 循环,直到以 Angular 拒绝

javascript - Vue.js 变量变为未定义

php - 在 Laravel 中找到交点的最佳方法

php - 使用 php 和 mysqli 的动态图像 slider

javascript - 从 React 组件函数中的另一个文档调用普通的 javascript 函数

Javascript如何确保显示JQuery .append

java - Java 服务器和浏览器客户端之间乐观对象复制的解决方案?

javascript - Three.js 无后台导入gltf

php - Mysqli 显示一行中的表内容和未从数据库中检索到的列名

php - 分页和行编号