-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
74 lines (61 loc) · 1.56 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
74
<!doctype html>
<html>
<head>
<style>
.options {
border: 1px solid black;
padding: 10px;
}
input,
filter-by-text,
filter-by-text-styled {
margin-bottom: 10px;
}
</style>
<link rel="import" href="filter-by-text.html">
<link rel="import" href="filter-by-text-styled.html">
</head>
<body>
<div class="options">
<input placeholder="Search" value="berry">
<filter-by-text filterText="berry">
<div>Apple</div>
<div>Blueberry</div>
<div>Currant</div>
<div>Goji berry</div>
<div>Honeydew</div>
<div>Lemon</div>
<div>Mangosteen</div>
<div>Papaya</div>
<div>Pineapple</div>
<div>Prickly Pear</div>
<div>Watermelon</div>
</filter-by-text>
<input placeholder="Search" value="pple">
<filter-by-text-styled filterText="pple">
<div>Apple</div>
<div>Blueberry</div>
<div>Currant</div>
<div>Goji berry</div>
<div>Honeydew</div>
<div>Lemon</div>
<div>Mangosteen</div>
<div>Papaya</div>
<div>Pineapple</div>
<div>Prickly Pear</div>
<div>Watermelon</div>
</filter-by-text-styled>
</div>
<script>
Array.prototype.forEach.call(document.querySelectorAll('.options input'), function(search) {
var results = search.nextElementSibling;
search.addEventListener('input', function() {
results.filterText = search.value;
});
results.addEventListener('change', function(event) {
console.log(event.detail.innerText);
});
});
</script>
</body>
</html>