-
Notifications
You must be signed in to change notification settings - Fork 0
/
addClass.html
87 lines (64 loc) · 1.51 KB
/
addClass.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
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">google.load("jquery", "1");</script>
<style>
.current {
color:green;
}
.completed {
color:blue;
}
</style>
</head>
<body>
if(selected.val() == 'complete'){
$("#completion_date").show();
}
else
{
$("#completion_date").hide();
}
$("div").each(function (i) {
if (this.style.color != "blue") {
this.style.color = "blue";
} else {
this.style.color = "";
}
});
<p>
<label class="status">current</label>
<label class="status">completed</label>
<label class="status">current</label>
<label id='new'></label>
</p>
<table><tr><td class="status">current</td><td class="status">complete</td></tr></table>
</body>
</html>
<script type="text/javascript">
$('document').ready(function(){
/* works but need to iterate through each label with a class of status.
$(function(){
if($('.status:first').text() == 'current') {
$('.status:first').addClass('current');
}
//$('.status').addClass('current');
var str = $('label:first').text();
$('#new').text(str);
});
*/
$(function(){
$('label.status, td.status').each(function (i){
if ($(this).text() == 'current'){
$(this).addClass('current');
}
if ($(this).text() == 'completed'){
$(this).addClass('completed');
}
});
});
});
</script>