How to print div content using javascript

Print div content using JavaScript, javascript – Print the contents of a DIV, print div content without plugin, print div content jquery, how to print a particular div using javascript, javascript print div content only, javascript print div not working in Internet Explorer solved.

Print web page specific div or section using small JavaScript function. JavaScript technique not work some time in Internet Explorer or div/section design not comes in print output. Here some more stuff added for solving above issues. demo and code sample given below.

Add JavaScript code:

<script>
function printDiv(eleId){
    var PW = window.open('', '_blank', 'Print content');
 
    //IF YOU HAVE DIV STYLE IN CSS, REMOVE BELOW COMMENT AND ADD CSS ADDRESS
    //PW.document.write('<link rel="stylesheet" type="text/css" href="CSS-FILE-ADDRESS"/>');
 
    PW.document.write(document.getElementById(eleId).innerHTML);
    PW.document.close();
    PW.focus();
    PW.print();
    PW.close();
}
</script>

Wrap your div/section with special div:

<div id="printMe">
    <YOUR PRINT SECTION START>
    </YOUR PRINT SECTION END>
</div>

Add button for trigger print command:

<button onclick="printDiv('printMe');">Print DIV</button>

Demo for print div content using javascript

Print div demo title

Plan 1 2 Year
Plan 1 2 Year
Plan 1 2 Year