有办法用jQuery操纵@媒体打印吗?
我有一个表,我想计算行数,如果行数大于一个特定的数字,我将应用分页后。
$('.print').on('click', function () {
var r = 0;
$('.invoice table tbody tr').each(function () {
r+=1;
if(r == 30){
if($('.footer').css('display') == 'none'){
$('.invoice table tbody').css('page-break-after', 'always');
}
}
})
哪里
发布于 2017-01-08 01:22:59
对类使用css样式规则,并在适用的情况下添加该类。类似于:
var numRows = $('.invoice table tbody tr').length;
if(numRows >= 30 && !$('.footer:visible').length ){
$('.invoice table tbody').addClass('page-break-class')
}
CSS
@media print {
tbody.page-break-class {page-break-after: always;}
}
https://stackoverflow.com/questions/41528392
复制相似问题