-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
73 lines (73 loc) · 3.16 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>Material Design Lite editable table</title>
<link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.indigo-pink.min.css">
<script defer src="https://code.getmdl.io/1.1.3/material.min.js"></script>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<style>
.table-remove:hover {
color: #f00;
cursor: pointer;
}
.table-add:hover {
cursor: pointer;
color: #0b0;
}
</style>
</head>
<body>
<br>
<br>
<div class="mdl-grid">
<div class="mdl-layout-spacer"></div>
<div class="mdl-cell mdl-cell--4-col">
<table class="mdl-data-table mdl-shadow--2dp">
<thead>
<tr class="mdl-js-button mdl-button--raised mdl-button--accent">
<th style="color:white;text-align: center;" colspan="100%">Table description</th>
</tr>
<tr class="mdl-js-button mdl-button--raised mdl-button--colored">
<th style="color:white;text-align: center;">Column 1</th>
<th style="color:white;text-align: center;">Column 2</th>
<th style="color:white;text-align: center;"><i style="vertical-align: bottom;" class="table-add material-icons md-24"> </i></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div contentEditable style="width: 100%; height: 100%;">Cell 1</div>
</td>
<td>
<div contentEditable style="width: 100%; height: 100%;">Cell 2</div>
</td>
<td><i style="vertical-align: bottom;" class="table-remove material-icons md-24"></i></td>
</tr>
<!-- This is our clonable table line -->
<tr class="hide" style="display:none;">
<td>
<div contentEditable style="width: 100%; height: 100%;">Cell 1</div>
</td>
<td>
<div contentEditable style="width: 100%; height: 100%;">Cell 2</div>
</td>
<td><i style="vertical-align: bottom;" class="table-remove material-icons md-24"></i></td>
</tr>
</tbody>
</table>
</div>
<div class="mdl-layout-spacer"></div>
</div>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js'></script>
<script>
$('.table-add').click(function() {
var $clone = $(this).closest('table').find('tr.hide').clone(true).removeClass('hide').toggle();
$(this).closest('table').append($clone);
});
$('.table-remove').click(function() {
$(this).parents('tr').detach();
});
</script>
</body>
</html>