本帖最后由 angryBirds2014 于 2014-08-01 18:18:59 编辑

解决方案 »

  1.   


    <!doctype html>
    <html lang="en-US">
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            .content_bg
            {
                width:100%;
                height:100%;
                color:red;
                background: #ccc;
                /*background-image:url("../images/2.gif");*/        }
        </style>
    </head>
    <body>
    <div  id="content_bg" class="content_bg">
        <div class="content_font" style="text-align: center;">
            <ul style="list-style: none; float: left; width: 200px; height: 204px">
                <span>3C</span>
                <li>hello</li>
                <li>hello</li>
                <li>hello</li>
                <li>hello</li>
                <li>hello</li>
            </ul>
            <ul style="list-style: none; float: left; width: 200px; height: 204px">
                <span>3C</span>
                <li>hello</li>
                <li>hello</li>
                <li>hello</li>
                <li>hello</li>
                <li>hello</li>
            </ul>
            <ul style="list-style: none; float: left; width: 200px; height: 204px">
                <span>3C</span>
                <li>hello</li>
                <li>hello</li>
                <li>hello</li>
                <li>hello</li>
                <li>hello</li>
            </ul>
        </div>
    </div>
    <script type="text/javascript">
        function getStyle(obj, name){
            if(obj.currentStyle){
                return obj.currentStyle[name];
            } else {
                return getComputedStyle(obj, false)[name];
            }
        }    window.onload = pageOnload;
        function pageOnload() {
            var bg = document.getElementById("content_bg");
            var d = getStyle(bg, 'backgroundColor');
            alert(d);
        }    function changeBg(num) {
            //bg.background = num + ".gif";
            //bg.style.backgroundImage =  "../images/"+num+".gif";
            // alert(bg.style.backgroundImage);
            //alert("../images/"+num+".gif");
            alert(bg.style.backgroundImage);
        }
    </script>
    </body>
    </html>