2011-04-28 80 views
0

我不知道我在做什么错,但列表的项目符号不会改变,请帮助。javascript getElementById for listStyle

这是HTML

<div id="recetas_prepa"> 
<p class="recetas_preparacion">Preparación</p> 
<ul id="recetas_preparacion_lista"> 
    <li>Quitar aomo de 1 o 2 cm, salpimentándolas a continuación. 
    </li> 
    <li>En picado y la Mostaza Para CUando, removiéndolo todo. 
    </li> 
    <li>A de un poco de arroz blanco, unos champiñones o patatas hervidas. 
    </li> 
</ul> 
</div> 

这是CSS

#recetas_prepa{ 
    width:480px; 
    height:auto; 
    overflow:hidden; 
    background-color:lime; 
    clear:both; 
    margin-top:10px; 
    margin-left:20px; 
    margin-bottom:15px; 
} 
#recetas_preparacion_lista li{ 
    color:#333333; 
    font-family: Verdana, sans-serif; 
    font-size:10px; 
    text-align:left; 
    padding:8px 15px 0px 12px; 
    list-style:decimal inside none; 
} 

,这是我的JS:

<script language="javascript" type="text/javascript"> 
    function changeDiv() 
    { 
     var imgPath = new String(); 
     imgPath = document.getElementById("recetas_info").style.display; 

     if(imgPath == "inline" || imgPath == "") 
     { 
      document.getElementById("recetas_info").style.display = "none"; 
      document.getElementById("recetas_ingre").style.display = "none"; 
      document.getElementById("recetas_prepa").style.clear = "none"; 
      document.getElementById("recetas_prepa").style.width = "350px"; 
      document.getElementById("recetas_prepa").style.height = "90px"; 
      document.getElementById("recetas_preparacion_lista").style.listStyle = "disc inside none"; 
     } 
     else 
     { 
      document.getElementById("recetas_info").style.display = "inline"; 
      document.getElementById("recetas_ingre").style.display = "inline"; 
      document.getElementById("recetas_prepa").style.clear = "both"; 
      document.getElementById("recetas_prepa").style.width = "480px"; 
      document.getElementById("recetas_prepa").style.height = "auto"; 
     } 
    } 
</script> 

还有一些其他的东西存在,但在最后的如果,我的意思是这条线:

document.getElementById("recetas_preparacion_lista").style.listStyle = "disc inside none"; 

是一个不工作,我不知道为什么,它只是不会改变。

+0

是U确保您的功能changeDiv()调用的任何地方? – Vijay 2011-04-28 07:24:53

回答

1

你应该你的CSS改变

#recetas_preparacion_lista li{ 
    color:#333333; 
    font-family: Verdana, sans-serif; 
    font-size:10px; 
    text-align:left; 
    padding:8px 15px 0px 12px; 
} 

,并添加

#recetas_preparacion_lista{ 
    list-style:decimal inside none; 
} 

您的代码将现在的工作,因为CSS是不那么事实上重写你的JavaScript解决,而在ul元素CSS地址li元素。

演示在http://jsfiddle.net/gaby/SHCYw/