javascript - UL 标签不显示与 OL 相同的 css

标签 javascript html css html-lists unordered

我有这个 javascript Accordion (.heading),我正在尝试将它应用于无序列表(第一个“ul”标记)。奇怪的是格式(主要集中在悬停颜色上)适用于有序列表,而不适用于“ul”标签。

HTML

<h3><a></a></h3>
  <div>
    <ul>
    <li class="heading"></li>
    <ul class="content">
            <li></li>
            <li></li>
            <li></li>

        </ul>   
    <li></li>   
    </ul>
  </div> 

CSS

.heading {
margin: 1px;
color: black;
padding: 3px 10px;
cursor: pointer;
position: relative;
font-weight: bold;
}

.heading:hover{
margin: 1px;
color: black;
padding: 3px 10px;
cursor: pointer;
position: relative;
font-weight: bold;
background:#cccccc
}

.content {
padding: 5px 10px;
}
p { padding: 5px 0; }

感谢您的帮助。

编辑:

这是我在

中输入的javascript脚本
 <script type="text/javascript">
jQuery(document).ready(function() {
 jQuery(".content").hide();
  //toggle the componenet with class msg_body
  jQuery(".heading").click(function()
  {
    jQuery(this).next(".content").slideToggle(500);
  });
});
</script>

最佳答案

您的列表嵌套不正确。嵌套列表需要位于 li 元素内,而不是第一个 ul 的直接子元素。

关于javascript - UL 标签不显示与 OL 相同的 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22001748/

相关文章:

html垂直对齐并在h2标签中居中对齐

javascript - 如何正确取消嵌套 jquery javascript 函数?

css - 右侧的 HTML/CSS : Boostrap3 div placement with 2 on left, 1

html - 固定位置的div无法滚动

html - 下一个/同级/后续 HTML 元素的 XPath?

css - 如何在 CSS 工作表中设置 wiki 表格格式类?

javascript - 使用 HTML 和 Javascript 每天显示消息直到消息结束

javascript - UIWebView什么时候完成图像加载?

javascript - 对 boolean 函数数组运行reduce。它总是返回 true,并且如果返回 false,则无法找到一种方法来突破 reduce 方法

javascript - JavaScript 中的 document.popledLayer 是什么?