Today, We want to share with you print div in javascript.In this post we will show you To print the data content of div in js, added content of div in a js variable after that the print button is clicked, hear for Print the content of a div element using JavaScript we will give you demo and example for implement.In this post, we will learn about jQuery Print Dynamic Content using PHP MySQL with an example.
How to print div content using javascript/jQuery?
Example 1: index.html
Document I am inside the div tag...
I am not inside the div tag...
JS: Print content of div
HTML Code
JS: Print content of div
This will be printed
This won't be printed
CSS Code
.hidden { display:none; } body { background: #edfffe; }
JS Code
document.getElementById("writeNameOnPictureDownload").addEventListener("click", function() { var printContents = document.getElementById('pageDataDisplay').innerHTML; var originalContents = document.body.innerHTML; document.body.innerHTML = printContents; window.print(); document.body.innerHTML = originalContents; });
I hope you get an idea about div content with background image javascript.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.