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,432 |
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 |
Smooth Scroll To Anchor With jQuery | 1,976 Kb |
Add id to body tag based on url jQuery | 1,501 Kb |
Sticky Navigation or Section with jQuery | 2,297 Kb |
Sample fancybox 2 overlay with no wrapper and custom close | 1,937 Kb |
QA list with content property | 1,628 Kb |
Img Swap on hover or mouseover with JQuery | 1,561 Kb |
Placeholder sample for IE | 2,578 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 |
Spinners using Font Icons | Keyamoon | 3,007 Kb |
TheCalendar.js | The-teacher | 6,330 Kb |
A vuejs widget | Chrgl86 | 2,869 Kb |
Incremental game | Eprouver | 5,868 Kb |
Fullscreen Parallax | Bassta | 3,313 Kb |
About Mazano | Kiti | 2,585 Kb |
GrcJS | Vino6 | 2,047 Kb |
Cars going | Netoguimaraes | 1,699 Kb |
CSS3 Form Page Design | Rssatnam | 3,613 Kb |
React Recipe Box | Krokodill | 5,347 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!