javascriptを使う:隔行の変色を実現する
1341 ワード
</code></pre><table align="center" border="black 1px sold">
<thead>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</thead>
<tbody id="tb">
<tr>
<td>1</td>
<td> </td>
<td>12</td>
</tr>
<tr>
<td>2</td>
<td> </td>
<td>45</td>
</tr>
<tr>
<td>3</td>
<td> </td>
<td>23</td>
</tr>
<tr>
<td>4</td>
<td> </td>
<td>34</td>
</tr>
</tbody>
</table>
<script type="text/javascript">
var tbs = document.getElementById("tb");
for(var i=0; i<tbs.rows.length;i++ ){
if(i%2==0){
tbs.rows[i].style.backgroundColor="red";
}else{
tbs.rows[i].style.backgroundColor="blue";
}
}
</script>
</div>
</div>
</div>
</div>