jQuery: Print a page
jQuery Practical exercise Part - I : Exercise-8
Print a page using jQuery.
HTML Code :
<body><div> <a class="printPage" href="#">Print</a> </div> </body>
Sample solution :
HTML Code :
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<meta charset="utf-8">
<title>Print a page using jQuery</title>
</head>
<body>
<div>
<a class="printPage" href="#">Print</a>
</div>
</body>
</html>
JavaScript Code :
$('a.printPage').click(function(){
window.print();
return false;
});
See the Pen jquery-practical-exercise-8 by w3resource (@w3resource) on CodePen.
Contribute your code and comments through Disqus.
Previous: Create a Zebra Stripes table effect.
Next: Limit character input in the textarea including count.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- JavaScript functions Exercises
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises