我想在JS里调用一个函数可以改变背影色,或其它一些属性应该怎么写啊...
下面这个是想使背影变色...这么写可以实面么...有没有好点的方法.....
function hid(){

document.getElementById("divDown").style.display='block';
document.getElementById("divDown").style.bgColor="blue";
}

解决方案 »

  1.   

    document.getElementById("divDown").style.backgroundColor="blue";
      

  2.   


    function hid(){ 
        var div = document.getElementById("divDown");
        div.style.display='block'; 
        div.style.backgroundColor="blue"; 
    }
      

  3.   

    <style type="text/css">
    <!--
    html,body {height:100%; margin:0px; font-size:12px;}.mydiv {
    background-color: #f9fff6;
    border: 1px solid #009900;
    text-align: center;
    line-height: 25px;
    font-size: 13px;
    font-weight: bold;
    z-index:99;
    width: 300px;
    height: 50px;
    left:50%;/*FF IE7*/
    top:50%;/*FF IE7*/margin-left:-150px!important;/*FF IE7 half of its width */
    margin-top:-60px!important;/*FF IE7 half of its height*/margin-top:0px;position:fixed!important;/*FF IE7*/
    position:absolute;/*IE6*/_top:       expression(eval(document.compatMode &&
                document.compatMode=='CSS1Compat') ?
                documentElement.scrollTop + (document.documentElement.clientHeight-this.offsetHeight)/2 :/*IE6*/
                document.body.scrollTop + (document.body.clientHeight - this.clientHeight)/2);/*IE5 IE5.5*/}
    .bg {
    background-color: #C2BEBF;
    width: 100%;
    height: 100%;
    left:0;
    top:0;/*FF IE7*/
    filter:alpha(opacity=40);/*IE*/
    opacity:0.4;/*FF*/
    z-index:1;position:fixed!important;/*FF IE7*/
    position:absolute;/*IE6*/_top:       expression(eval(document.compatMode &&
                document.compatMode=='CSS1Compat') ?
                documentElement.scrollTop + (document.documentElement.clientHeight-this.offsetHeight)/2 :/*IE6*/
                document.body.scrollTop + (document.body.clientHeight - this.clientHeight)/2);/*IE5 IE5.5*/} 
    --> 
    </style>
    <script language="javascript" type="text/javascript">
    function showDiv(){
    if(document.all){
        document.getElementById('bg').innerHTML = "<iframe style='width:100%;height:100%;left:0px;top:0px;position:absolute;filter:alpha(opacity=0);z-index:-1;border:0px'/>";
    }
    document.getElementById('popDiv').style.display='block';
    document.getElementById('bg').style.display='block';
    }function closeDiv(){
    document.getElementById('popDiv').style.display='none';
    document.getElementById('bg').style.display='none';
    }</script>
    <div id="popDiv" class="mydiv" style="display:none;">文件输出字样<br/>
    <!--<a href="javascript:closeDiv()">close</a>--></div>
    <div id="bg" class="bg" style="display:none;"></div><!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=gb2312" />
    <title>弹出半透明层 (支持IE FF)</title></head><body>
    <form id="frm1" name="frm1" action="new_page_2.htm" method="post">
    <input type="button" value="Show DIV" onclick="showDiv()" />
    <select><option >test</option></select>
    <br><br><br><br>
    <select name="selOccPool" multiple="multiple"  size="6"  style="width:20%"  id="selOccPool">
                        
    <option value = "**All**" selected="true">**All**</option>
    <option value="6A">6A</option>
    <option value="6B">6B</option>
    <option value="6C">6C</option>
    <option value="6D">6D</option>
    <option value="6E">6E</option>
    <option value="6F">6F</option>
    <option value="6G">6G</option>
    </select>
    </form>
    </body>
    </html>
      

  4.   

    function hid(){ 
        var div = document.getElementById("divDown");
        div.style.display='block'; 
        div.style.backgroundColor="blue"; 
    }
      

  5.   

    这段是什么意思啊?
    在<HTML>外面写的啊?
    <div id="bg" class="bg" style="display:none;"></div>