What’s a scenario where you would need to print specific contents only? Well…how about not wanting all the header, footer, and sidebar stuff in your print. That seems pretty common enough 🙂
For an explanation look at the comments in the code.
Alternative Method Using jQuery.Print.js
This method has a lot more options and it’s easier to call the print function, but the additional plugin you need to include does add a little bit of weight to your page. To see a full list of options for this plugin check out the author’s github. Code example below.
See the Pen Print Specific Section of a Page Using jQuery.Print.js by Mike Doubintchik (@allurewebsolutions) on CodePen.
As always the code is commented and if you have any questions, please ask in the comments below.