Reputation: 537
I've been trying to use the jquery.printElement plugin but nothing happens when I click on the Print link, except for this error message in the console:
Uncaught TypeError: Cannot read property 'opera' of undefined
The code I'm using is as follows:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Print</title>
</head>
<body>
<p id="content">Some text to print</p>
<a href="#" id="printIt">Print</a>
<script src="../common/js/jquery-1.10.1.min.js"></script>
<script src="../common/js/jquery.printElement.js"></script>
<script>
$('#printIt').click(function() {
$('#content').printElement();
});
</script>
</body>
</html>
Anyone know why this is happening?
Upvotes: 0
Views: 3609
Reputation: 318352
The printElement plugin uses jQuery.browser internally, and $.browser has been deprecated and removed in the version of jQuery you're using.
You have to use an older version of jQuery, or possibly the migrate plugin to make printElement work.
Upvotes: 5
Reputation: 27382
wrap code inside document.ready
.
$(function()
{
$('#printIt').click(function()
{
$('#content').printElement();
});
});
Upvotes: 0