Print html table content to printer using jQuery

By | July 22, 2015

Print html table content to printer using jQuery

[dropcap]I[/dropcap]n this tutorial we are going to see how we can print a particular html content in a page to the printer instead of printing the whole page or without navigating to other window.

To do this let’s consider that we want to print contents which are in a table. We have to first set a id to the div which surrounds the table.

Now we have to first get the contents inside the body tag to a variable. Because we need to replace this content once we print the table. The next step is to get the content inside the div with id “printThisTable” and assign it to a variable.

Replace the second variable content to the body tag and call print function. Once you called the print function you can replace the variable which contains contents of the body tag to the body tag.

Check the below code which is used to Print html table content to printer using jQuery

🔥1

Leave a Reply