listStyle 的 javascript getElementById

发布于 2024-11-04 03:26:32 字数 2350 浏览 5 评论 0原文

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

这是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

落花浅忆 2024-11-11 03:26:32

您应该将您的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/

You should change your css to

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

and add

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

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 the li elements.

demo at http://jsfiddle.net/gaby/SHCYw/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文