Print element on a page
How do I make an print element on a page?
What is a print element on a page? How do you make a print element on a page? This script and codes were developed by Mia Sno on 12 August 2022, Friday.
Print element on a page - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Print element on a page</title>
</head>
<body> <div class="content_blocks">
<div>
<p>CONTENT 1:</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent tempus, erat et sagittis lacinia, magna nunc laoreet odio, non adipiscing ipsum tellus a lorem. Sed non commodo nisl, sit amet aliquam turpis. Sed gravida elementum nunc ut luctus. Nulla facilisi. Nam euismod blandit porttitor.</p>
<p><a href="javascript:void" class="printThis">Print this block</a></p>
</div>
<div>
<p>CONTENT 2:</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent tempus, erat et sagittis lacinia, magna nunc laoreet odio, non adipiscing ipsum tellus a lorem. Sed non commodo nisl, sit amet aliquam turpis. Sed gravida elementum nunc ut luctus. Nulla facilisi. Nam euismod blandit porttitor.</p>
<p><a href="javascript:void" class="printThis">Print this block</a></p>
</div>
</div> <script src='http://equalsquote.com/wp-includes/js/jquery/jquery.js?ver=1.8.3'></script> <script src="js/index.js"></script>
</body>
</html>
Print element on a page - Script Codes JS Codes
$(document).ready(function () {
$('.printThis').click(function() {
var content_data = $(this).closest('div').html(); // this variable contains html of this content
var printPage=window.open("toolbar=yes,location=no,directories=yes,menubar=yes,scrollbars=yes,width=650, height=400, left=100, top=25"); // open popup settings with margins for top and left printPage.document.write('<html><head><title>My Desired Content</title>'); //page html markup printPage.document.write('<link rel="stylesheet" href="print.css" type="text/css" />');//page css to make it look print-friendly - optional of course printPage.document.write('</head><body >'); //page html markup printPage.document.write(content_data); // drop in the html variable we declared above printPage.document.write('</body></html>'); //page html markup printPage.print(); // open print dialogue box printPage.close(); // close the popup once the print dialogue box is done return true; }); });

Developer | Mia Sno |
Username | mrs_snow |
Uploaded | August 12, 2022 |
Rating | 3 |
Size | 2,081 Kb |
Views | 36,414 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
QA list with content property | 1,628 Kb |
Placeholder sample for IE | 2,578 Kb |
Sticky Navigation or Section with jQuery | 2,297 Kb |
Smooth Scroll To Anchor With jQuery | 1,976 Kb |
Add id to body tag based on url jQuery | 1,501 Kb |
Sample fancybox 2 overlay with no wrapper and custom close | 1,937 Kb |
Img Swap on hover or mouseover with JQuery | 1,561 Kb |
Toggle graph phases with menu of phases | 3,030 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Jochaho Skeleton | Dhanushbadge | 1,689 Kb |
Pomodoro Clock | Yas46 | 3,328 Kb |
Z-index demo | Kblh | 1,534 Kb |
A Pen by Patrick Cox | Pcridesagain | 2,899 Kb |
Responsive Table-less Shopping Cart | Alex_rodrigues | 6,637 Kb |
Plotting Points with D3.js | Laurakelly | 31,996 Kb |
LeMandinque | Aadesida | 9,046 Kb |
Javascript Welcome | Peterlewicki | 1,573 Kb |
After America | Jonathangarner | 2,686 Kb |
The CodePen Logo | Kindofone | 4,259 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!