开发者

Display div only as per selection from menu list n hide rest of them

i have a Menu in which when user selects from menu list it displays that div and rest are hidden i have a huge menu list is there any function such that it displays开发者_StackOverflow中文版 only that div Can Anyone help please....


HTML:

<ul>
   <li class="one">One</li>
   <li class="two">Two</li>
   <li class="three">Three</li>
</ul>

<div id="one"> Div one </div>
<div id="two"> Div two </div>
<div id="three"> Div three</div>

CSS:

div {
    display:none;
}

li {
    cursor:pointer;
}

JQuery:

$('li').click(function(){
    $('div#' + $(this).attr('class')).show().siblings().hide();
});


This isn't a particularly well phrased question, but i'm thinking you want to give all your divs that can be shown a particular class, and give each ond an id:

<div class="revealPanel" id="panel1">
<!-- Content -->
</div>

<div class="revealPanel" id="panel2">
<!-- Content -->
</div>

<div class="revealPanel" id="panel3">
<!-- Content -->
</div>
<!-- etc. ... -->

You've tagged this query with jquery-ajax so I'm going to assume you know how to include jQuery in your page etc.. Define a javascript function to hide all divs and show a specified one:

function ShowPanel(panelId)
{
    jQuery('.revealPanel').hide();

    if (panelId != null)
    {
        jQuery(panelId).show();
    }
}

And now just call that function from each of your menu links with the correct id, for instance:

<a href="javascript:ShowPanel('panel1');>Show Panel 1</a>

Of course I may have misinterpreted your question, and even if I haven't I encourage you to provide more detail in your questions — use code snippets to show how you've designed your menu etc.

Good luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜