在jquery中保持第一个菜单项展开

在jquery中保持第一个菜单项展开,jquery,css,jquery-ui-accordion,Jquery,Css,Jquery Ui Accordion,我有3个用HTML设计的菜单项。 我希望我的第一个菜单项在默认情况下展开 这是我的小提琴: 发布我随身携带的物品: HTML 风格 一切正常,但我希望第一个菜单项在默认情况下展开。 请温柔一点,我是JQuery的新手 您只需添加CSS即可: .example_menu li:first-of-type ul{ display:block; } 如果您可以在jsfiddle.net中发布上述内容,那将是非常受欢迎的:)如果您有jsfiddle,那就太好了,否则每个人都必须复制相同的代码-

我有3个用HTML设计的菜单项。 我希望我的第一个菜单项在默认情况下展开

这是我的小提琴:

发布我随身携带的物品:

HTML

风格

一切正常,但我希望第一个菜单项在默认情况下展开。 请温柔一点,我是JQuery的新手

您只需添加CSS即可:

.example_menu li:first-of-type ul{
    display:block;
}

如果您可以在jsfiddle.net中发布上述内容,那将是非常受欢迎的:)如果您有jsfiddle,那就太好了,否则每个人都必须复制相同的代码-您能帮忙吗?它仍然为我显示相同的结果。我复制了相同的代码。。奇怪,但仍然只显示旧的结果。@TouhidK。-很难说,鉴于提供的代码(在小提琴中)它是有效的,不确定任何未提供的代码中还有什么可能冲突:(
$(document).ready(function () {
    $('#menu1  li a').click(function () {
        $(this).parent().children('ul').slideToggle('medium').toggleClass('collapsed').toggleClass('expanded');
        //$(this).parent('ul').slideToggle('medium').toggleClass('collapsed').toggleClass('expanded');
        $(this).parent().children('div').slideToggle('medium').toggleClass('collapsed').toggleClass('expanded');
    });
});
body {
    font: 10pt Arial, Helvetica, Sans-serif;
    background-image: url();
    margin: 0px;
}

a {
    text-decoration: none;
}

#example1, #example2, #example3, #example4, #example5 {
    float: left;
}

.expand_all, .collapse_all {
    cursor: pointer;
}

.example_menu {
    font-size: 95%;
    list-style: none;
    margin: 0;
    padding: 0;
    vertical-align: top;
    width: 100%;
}

.example_menu ul {
    display: none;
    list-style: none;
    margin: 0;
    padding: 0;
}

#menu1, #menu2, #menu3, #menu4, #menu5 {
    margin: 0;
    color: #96C;
}

#menu1 li, #menu2 li, #menu3 li, #menu4 li, #menu5 li, .example_menu li {
    background-image: none;
    margin: 0;
    padding: 0;
}

.example_menu ul ul {
    display: block;
}

.example_menu ul ul li a {
    padding-left: 20px;
    width: 99%;
}

.example_menu li.header3 a {
    padding-left: 34px;
    width: 98%;
}

.example_menu a {
    color: #000;
    cursor: pointer;
    display: block;
    font-weight: bold;
    margin-left: 0;
    width: 99%;
    padding-top: 18px;
    padding-right: 0px;
    padding-bottom: 12px;
    padding-left: 19px;
}

.example_menu a.expanded {
    background: #bbb url('images/collapse.gif') no-repeat 3px 61%;
}

.example_menu a.collapsed {
    border-top: 1px solid #E3E3E3;
    background-color: #bbb;
    background-image: url(images/expand.gif);
    background-repeat: no-repeat;
    background-position: 3px 61%;
}

a.collapsed + ul {
    display: none;
}

.example_menu a.normal {
    background: none repeat scroll 0 0 #BBBBBB;
}

.example_menu a:hover {
    text-decoration: none;
}

.example_menu ul a {
    background: #e8e8e8;
    border-top: 2px solid #fff;
    color: #000;
    display: block;
    font-weight: normal;
    padding: 3px 8px 2px 17px;
    width: 98%;
}

.example_menu ul a:link {
    font-weight: bolder;
}

.example_menu ul a:hover {
    background: #f5f5f5;
    text-decoration: underline;
}

.example_menu li.active a {
    background: #fff;
}

.example_menu li.active li a {
    background: #e8e8e8;
}

#menu1 li.footer, #menu2 li.footer, #menu3 li.footer, #menu4 li.footer, #menu5 li.footer, .example_menu .footer {
    background: transparent url('images/footer.jpg') no-repeat 0 0;
    border-top: 2px solid #fff;
    height: 9px;
    line-height: 15px;
    margin: 0 0 10px 0;
    width: 95%;
}

.example_menu .footer span {
    display: none;
}
.example_menu li:first-of-type ul{
    display:block;
}