JSFiddle - React, Tailwind, and code Playground
by velo_ninja
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Print PDF Example</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>This is some content that will be printed.</p>
<!-- Print button -->
<button id="printButton">Print this page</button>
<!-- JavaScript -->
<script>
const printButton = document.getElementById('printButton');
// Attach an event listener to the button to trigger the print function
printButton.addEventListener('click', function() {
window.print(); // This opens the browser's print dialog
});
</script>
</body>
</html>