用JavaScript改变table的背景色

用JavaScript改变table的背景色_第1张图片

index.html:




    
    Title
    


    
Itinerary
When Where
June 9th Poratland,OR
June 10th Poratland,OR
June 11th Poratland,OR

format.css:

body{
    background-color: #fff;
    color: #000;
}

table{
    margin:auto;
    border:1px solid #699;
}

caption{
    margin:auto;
    padding: .2em;
    font-size: 1.2em;
    font-weight: bold;
}

th{
    font-weight: normal;
    font-style: italic;
    text-align: left;
    border:1px dotted #699;
    background-color: #9cc;
    color: #000;
}

th,td{
    width:10em;
    padding: .5em;
    text-align: center;
}

add.js:

function addLoadEvent(func){
    var oldonload = window.onload;
    if (typeof window.onload != 'function'){
        window.onload = func;
    }else {
        window.onload = function(){
            oldonload();
            func();
        }
    }
}

function stripeTables(){
    if (!document.getElementsByTagName) return false;
    var tables = document.getElementsByTagName("table");
    var odd,rows;
    for(var i=0; i


你可能感兴趣的:(JavaScript,CSS,HTML)