listStyle的javascript getElementById
我不知道我做错了什么,但列表中的项目符号不会改变,请帮忙 这是htmllistStyle的javascript getElementById,javascript,css,getelementbyid,Javascript,Css,Getelementbyid,我不知道我做错了什么,但列表中的项目符号不会改变,请帮忙 这是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. </
<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>
这是我的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>
是一个不起作用的,我不知道为什么,它只是不会改变。你应该将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
元素这一事实所覆盖
演示在您确定要在任何地方调用函数changeDiv()?
#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;
}