JQuery print part of div only

Posted in JQuery, Uncategorized on May 19th, 2010 by taswar

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

?View Code JAVASCRIPT
1
2
3
  $('#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:

1
 body { overflow: hidden; }

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

Share

3 Responses

  1. hadi Says:

    demo page will be helpful

  2. entio Says:

    i love You for this maaan

  3. afrofeel Says:

    Hey, why don’t you post the library so that we can also try it out.
    it’s a nice thing though.
    Thanks a lot

Leave a Comment