回答編集履歴

2

追記

2017/06/30 06:59

投稿

nnahito
nnahito

スコア2004

test CHANGED
@@ -49,3 +49,107 @@
49
49
 
50
50
 
51
51
  と言った感じですかね?
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+ # 追記
60
+
61
+
62
+
63
+ ```
64
+
65
+ <script src="https://code.jquery.com/jquery-3.2.1.js" integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE=" crossorigin="anonymous"></script>
66
+
67
+
68
+
69
+ <table>
70
+
71
+ <tr class="staff">
72
+
73
+ <td>1</td><td>A</td><td>AA</td><td>AAA</td><td>AAAA</td>
74
+
75
+ </tr>
76
+
77
+
78
+
79
+ <tr class="staff">
80
+
81
+ <td>2</td><td>B</td><td>BB</td><td>BBB</td><td>BBBB</td>
82
+
83
+ </tr>
84
+
85
+
86
+
87
+ <tr class="staff">
88
+
89
+ <td>3</td><td>C</td><td>CC</td><td>CCC</td><td>CCCC</td>
90
+
91
+ </tr>
92
+
93
+ </table>
94
+
95
+
96
+
97
+
98
+
99
+ <script>
100
+
101
+ $(function(){
102
+
103
+ $('tr:nth-of-type(1)').css('backgroundColor', 'gray');
104
+
105
+
106
+
107
+ // 1列目の色を解除
108
+
109
+ setOff(1);
110
+
111
+
112
+
113
+ // 2列目に色を付けてみる
114
+
115
+ setOn(2);
116
+
117
+ });
118
+
119
+
120
+
121
+
122
+
123
+ // こいつかな?
124
+
125
+ function setOn(num){
126
+
127
+ // 指定した列の色を変える
128
+
129
+ $('tr:nth-of-type('+ num +')').css('backgroundColor', 'gray');
130
+
131
+ }
132
+
133
+
134
+
135
+
136
+
137
+ // ついで
138
+
139
+ function setOff(num){
140
+
141
+ // 指定した列の色を元に戻す
142
+
143
+ $('tr:nth-of-type('+ num +')').css('backgroundColor', '');
144
+
145
+ }
146
+
147
+
148
+
149
+
150
+
151
+ </script>
152
+
153
+
154
+
155
+ ```

1

JSのミス修正

2017/06/30 06:59

投稿

nnahito
nnahito

スコア2004

test CHANGED
@@ -42,7 +42,7 @@
42
42
 
43
43
  ```
44
44
 
45
- $('.staff:nth-of-type(1)').css('backgroundColor', 'gray');
45
+ $('tr:nth-of-type(1)').css('backgroundColor', 'gray');
46
46
 
47
47
  ```
48
48