最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jquery交替變換顏色的三種方法 實例代碼

 更新時間:2013年11月19日 17:37:03   作者:  
這篇文章主要介紹了jquery交替變換顏色的三種方法,有需要的朋友可以參考一下

復制代碼 代碼如下:

<!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=utf-8" />
<title>even and odd</title>

<script type="text/javascript" src="jquery-1.4.4.js"></script>
<script type="text/javascript" language="javascript">
$(function(){
    alert("第一種");
    $("tbody tr:even").css("background-color", "red");
    $("tbody tr:odd").css("background-color", "yellow");

    alert("第二種");
    $("tbody tr").each(function (index){
                            alert(index);   
                            if(0 == index%2)
                            {
                                $(this).css("background-color", "blue");  
                            }
                            if(1 == index%2)
                            {
                                $(this).css("background-color", "green");  
                            }
                      });

    alert("第三種");
    rows = document.getElementsByTagName("tr");
    var length = rows.length;
    for(var i=0; i< length;i++){
       alert(i);
       if(0==i%2){
           rows[i].style.backgroundColor="#ffff00";
       }else
       {
           rows[i].style.backgroundColor="#0000FF";
       }      
   }
});
</script>

</head>

<body>
<table border="1">
<tbody >
    <tr> <td>aaa</td> <td>aaa</td> <td>aaa</td></tr>
    <tr> <td>bbb</td> <td>bbb</td> <td>bbb</td></tr>
    <tr> <td>aaa</td> <td>aaa</td> <td>aaa</td></tr>
    <tr> <td>bbb</td> <td>bbb</td> <td>bbb</td></tr>
    <tr> <td>aaa</td> <td>aaa</td> <td>aaa</td></tr>
    <tr> <td>bbb</td> <td>bbb</td> <td>bbb</td></tr>
</tbody>
</table>
</body>
</html>

相關文章

最新評論

岳普湖县| 盘山县| 桐柏县| 高平市| 黄冈市| 专栏| 五河县| 双辽市| 孝感市| 兴安盟| 桂东县| 乡城县| 重庆市| 长春市| 襄城县| 肥城市| 兰坪| 雅安市| 敦化市| 大洼县| 高阳县| 张北县| 麻阳| 彰武县| 巫山县| 花莲市| 美姑县| 德安县| 肇州县| 龙岩市| 吉木乃县| 始兴县| 龙游县| 宝清县| 新宁县| 长治县| 普格县| 和龙市| 宁明县| 定远县| 永和县|