forked from mdbootstrap/TW-Elements
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremovable-list-element.html
53 lines (49 loc) · 1.86 KB
/
removable-list-element.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
<!DOCTYPE html>
<html>
<head>
<link href="../css/perfect-scrollbar.css" rel="stylesheet">
<script src="../dist/perfect-scrollbar.js"></script>
<style>
#container {
border: 1px solid gray;
max-height: 300px;
width: 400px;
overflow: auto;
position: relative;
}
#container .element {
margin: 1px;
background-color: #cec;
height: 44px;
line-height: 44px;
}
</style>
</head>
<body>
<div id="container">
<div class="element">Hello! Click <a href="#">here</a> to remove this!</div>
<div class="element">Hello! Click <a href="#">here</a> to remove this!</div>
<div class="element">Hello! Click <a href="#">here</a> to remove this!</div>
<div class="element">Hello! Click <a href="#">here</a> to remove this!</div>
<div class="element">Hello! Click <a href="#">here</a> to remove this!</div>
<div class="element">Hello! Click <a href="#">here</a> to remove this!</div>
<div class="element">Hello! Click <a href="#">here</a> to remove this!</div>
<div class="element">Hello! Click <a href="#">here</a> to remove this!</div>
<div class="element">Hello! Click <a href="#">here</a> to remove this!</div>
<div class="element">Hello! Click <a href="#">here</a> to remove this!</div>
<div class="element">Hello! Click <a href="#">here</a> to remove this!</div>
<div class="element">Hello! Click <a href="#">here</a> to remove this!</div>
</div>
<script>
var $ = document.querySelector.bind(document);
var ps = new PerfectScrollbar('#container');
var container = $('#container');
[].forEach.call(container.querySelectorAll('.element'), function (el) {
el.querySelector('a').addEventListener('click', function () {
el.parentNode.removeChild(el);
ps.update();
});
});
</script>
</body>
</html>