Link to home
Start Free TrialLog in
Avatar of Demosthenes
Demosthenes

asked on

print only div jquery

Can you guys help me with this, I think this should be easy and I think I am close.  I want to print just a div, the div's ID is not exactly FormControl but has FormControl in it.  Firebug doesnt like the line with the print statement in it.  It say "TypeError: $(...).print is not a function ".

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>

$infopathdiv = $('div[id$="FormControl"]');

$(document).ready( function() {
  $("#printbutton").click(function(){$("#infopathdiv").print();});
});
</script>

<input id="printbutton" type="button" value="Print this page"/>

Open in new window

Avatar of Steve Bink
Steve Bink
Flag of United States of America image

Printing is not part of core jQuery, though some people have made plugins to do what you want.  Take a look at http://www.bennadel.com/blog/1591-ask-ben-print-part-of-a-web-page-with-jquery.htm, or google "jquery print".
ASKER CERTIFIED SOLUTION
Avatar of Demosthenes
Demosthenes

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Demosthenes
Demosthenes

ASKER

Found this code somewhere.