X

JQuery print part of div only

jquery

So here is an interesting jquery plugin called jqprint it allows one to specify any element and sent it to print.

Assuming you have an element with id printButton and a content area called divToPrint

  $('#printButton').live('click', function() {
                $('#divToPrint').jqprint();
            });

This will pop up the print functionality in your browser and send it with the default media=”print” css or else it picks up your default css. Kind of neat.

One thing to be mindful of in Firefox is the overflow attribute in your css stylesheet if you have overflow: hidden you will only get one page to print only.

Example:

 body { overflow: hidden; }

Remove the overflow and it would print all the pages of a div.

Categories: javascript JQuery
Taswar Bhatti:

View Comments (3)

Related Post