Net-informations.com

Print the content of a Div | JavaScript/jQuery

Printing a whole web-page is an easy task because it is a feature that is provided by web-browsers . However, in some situations, you may need to provide a functionality to your users for printing only a segment ( Div content ) of a web-page rather than the whole web page.

In the above code, when you click the button "Print a Div" , a JavaScript popup window is created and extracted the contents of the HTML div elements to store it in a JavaScript variable. Then the contents of the HTML div elements are written to the popup window and finally the window is printed using the JavaScript Window print() command.

run this source code Try it Yourself

Print This Image...

JS print Div

Full Source | JavaScript










net-informations.com (C) 2022    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.
SiteMap  | Terms  | About