Skip to content

Commit 71e7cf2

Browse files
Improve simple example
1 parent bcd4108 commit 71e7cf2

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

examples/simple.html

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,13 @@
11
<!DOCTYPE html>
2-
<html lang="en">
2+
<html>
33

44
<head>
55
<meta charset="UTF-8" />
66
<title>Simple example</title>
77
</head>
8-
<style>
9-
html {
10-
box-sizing: border-box;
11-
}
12-
13-
*,
14-
*:before,
15-
*:after {
16-
box-sizing: inherit;
17-
}
18-
</style>
198

209
<body>
21-
<button onclick="generate()">Generate pdf</button>
10+
<button id="create-btn">Create PDF</button>
2211

2312
<script src="libs/jspdf.js"></script>
2413
<script src="../dist/jspdf.plugin.autotable.js"></script>
@@ -55,12 +44,12 @@
5544
</table>
5645

5746
<script>
58-
function generate() {
59-
var doc = new jspdf.jsPDF()
47+
document.getElementById('create-btn').addEventListener('click', function () {
48+
const doc = new jspdf.jsPDF()
6049

6150
// Simple data example
62-
var head = [['ID', 'Country', 'Rank', 'Capital']]
63-
var body = [
51+
const head = [['ID', 'Country', 'Rank', 'Capital']]
52+
const body = [
6453
[1, 'Denmark', 7.526, 'Copenhagen'],
6554
[2, 'Switzerland', 7.509, 'Bern'],
6655
[3, 'Iceland', 7.501, 'Reykjavík'],
@@ -71,7 +60,7 @@
7160
doc.autoTable({ html: '#table' })
7261

7362
doc.save('table.pdf')
74-
}
63+
})
7564
</script>
7665
</body>
7766

0 commit comments

Comments
 (0)