HTML
<div id="printDiv">
<!-- content Here -->
</div>
<input type="button" value="Print" onclick="printDiv()"/>
JQuery
function printDiv()
{
$("#printDiv").print();
}
Это prinitng конкретного div при использовании Mozilla Firefox, но при использовании IE (версия 10) он печатает всю страницу.
Я использую этот плагин jQuery.
jQuery.print.js
Пожалуйста, помогите мне.
Вы можете сделать это без плагина. Я не знаю, делает ли этот плагин что-то дополнительное. Вам нужно будет написать пользовательскую функцию js для печати только div, а не всей страницы...
HTML
<div id="printDiv">
//content Here
</div>
JS
function customPrint(id) {
var cont = $('#'+id).html(),
pageCont = $('body').children();// Updated
/*Replace the page content with the div content that needs to be printed*/
$('body').html(cont);
/*Print function call*/
window.print();
/*Place the original page content back*/
$('body').html(pageCont);
}
customPrint("printDiv");
Обновить
function customPrint(id) {
var cont = $('#'+id),
pageCont = $('body');
/*Hide the page content*/
pageCont.hide();
cont.show();
/*Print function call*/
window.print();
/*Display back the page content*/
pageCont.show();
}