-
Notifications
You must be signed in to change notification settings - Fork 0
/
tutorial02.html
68 lines (63 loc) · 1.74 KB
/
tutorial02.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>jQuery Starterkit</title>
<link rel="stylesheet" type="text/css" media="screen" href="screen.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<script>
$(document).ready(function() {
var col_sel = ['text','number'];
$("#_table").find("thead:first th").each(function(index){
$(this).append("</br><input type='text' name= '"+index+"' class=filterText />")
;})
$('input.filterText').keyup(function() {
var col_ind = Number($(this).attr("name"));
var typed_val = $(this).val();
var col_pos = col_ind + 1;
if(col_sel[col_ind]=='number'){
$('#_table>tbody>tr>td:nth-child('+col_pos+')').each( function(){
if (parseFloat(typed_val) > parseFloat($(this).text()) ){
//$('#_table>tbody>tr').hide();}
($(this).parent().addClass("Test"))}
else {
$(this).parent().removeClass("Test");}
});
$("#_table>tbody>tr").show();
$(".Test").hide();
}
else {
//alert(col_pos);
var rows = $('#_table>tbody>tr').show();
rows.find('td:nth-child(1):not(:contains("'+typed_val+'"))').parent().hide();
};
});
});
</script>
<div id="_test">Here is the test div|</div>
<table id="_table">
<thead>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
</thead>
<tbody>
<tr>
<td>January</td>
<td>100</td>
</tr>
<tr>
<td>February</td>
<td>80</td>
</tr>
<tr>
<td>March</td>
<td>180</td>
</tr>
</tbody>
</table>
</body>
</html>