listStyle 的 javascript 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.
</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>
还有一些其他的东西,但最后一个 if,我的意思是这一行:
document.getElementById("recetas_preparacion_lista").style.listStyle = "disc inside none";
是不起作用的,我不知道为什么,它只是不会改变。
I have no idea what I'm doing wrong but the bullets of the list wont change, please help.
This is the 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>
And this is the 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;
}
and this is my 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>
There are some other stuff there but the the last of the if, i mean this line:
document.getElementById("recetas_preparacion_lista").style.listStyle = "disc inside none";
is the one that is not working, I have no idea why, it just wont change.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该将您的CSS更改为
并添加
您的代码现在可以工作了,因为CSS不会被覆盖,因为您的JavaScript地址为
ul
元素,而CSS地址为li
元素。演示位于 http://jsfiddle.net/gaby/SHCYw/
You should change your css to
and add
You code will work now, since the css is not overridden by then fact that your javascript addresses the
ul
element while the CSS addresses theli
elements.demo at http://jsfiddle.net/gaby/SHCYw/