-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.filter.html
More file actions
49 lines (46 loc) · 1.06 KB
/
jquery.filter.html
File metadata and controls
49 lines (46 loc) · 1.06 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script
src="https://code.jquery.com/jquery-3.1.1.min.js"
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
</head>
<body>
<input type="text" id="input">
<table id="table">
<tbody>
<tr>
<td>alex</td>
<td>cc</td>
</tr>
<tr>
<td>alop</td>
</tr>
<tr>
<td>cdf</td>
</tr>
<tr>
<td>coko</td>
<td>alex</td>
</tr>
<tr>
<td>cokoss</td>
</tr>
</tbody>
</table>
<script>
$(document).ready(function(){
$(document).on('keyup', '#input', function(e){
var value=$(this).val();
$('#table tr:has(td:contains("'+value+'"))').show();
$('#table tr:has(td:not(:contains("'+value+'")))').hide();
});
});
</script>
</body>
</html>