We always have to print a page. Many time we create a separate page for print but by using this code we can print any div. Just we need to put an id in the div and while calling the print function pass this id and cheers.....................
<div id="printableArea">
<h1>Print me</h1>
</div>
<input type="button" value="Print" class="submitbutton" onClick="printContent('feePrint');">
<script type="text/javascript">
function printContent(el){
var restorepage = $('body').html();
var printcontent = $('#' + el).clone();
$('body').empty().html(printcontent);
window.print();
$('body').html(restorepage);
}
</script>
<div id="printableArea">
<h1>Print me</h1>
</div>
<input type="button" value="Print" class="submitbutton" onClick="printContent('feePrint');">
<script type="text/javascript">
function printContent(el){
var restorepage = $('body').html();
var printcontent = $('#' + el).clone();
$('body').empty().html(printcontent);
window.print();
$('body').html(restorepage);
}
</script>
No comments:
Post a Comment