我想在打印页面中隐藏 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/