<html>
<head>
<title>jquery 打印指定區(qū)域內容</title>
<script src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
function printHtml(html) {
var bodyHtml = document.body.innerHTML;
document.body.innerHTML = html;
window.print();
document.body.innerHTML = bodyHtml;
}
function onprint() {
var html = $("#printArea").html();
printHtml(html);
}
</script>
</head>
<body>
<div>
<div id="printArea"
style="width: 500px; text-align: left;">
打印區(qū)域~~~~
</div>
<br />
<div>
<input type="button" id="btnPrint"
onclick="onprint()" value="print" />
</div>
</div>
</body>
</html>
對于在打印區(qū)域內不想被打印的按鈕等可以通過設置css
@media print { .noprint{display:none;} }