English 中文(简体)
JavaScript 菜单控制子菜单
原标题:JavaScript menu control sub-menu [closed]
最佳回答

满足对评论 < /强 > 所解释的需要的 < 强/强 >

在理解你需要什么(请下次试着解释一下你的问题)之后,这里有一个更新的 Fiddle that mgiht help you. 在这种情况下,我怀疑(如果我错了的话,纠正我)你不会使用与你网站的hashs的联系,而它所做的是搜索一个hash,这个hash,应该等于元素的名称(你可以突出它),你喜欢显示子菜单。例如:

您可以手动或使用 jquery :

$("#productNav ul li").each(function(){
    var title = $(this).children("a").attr("title");
    $(this).find("li a").attr("href",function(index,oldattr){
        return oldattr+"#"+title;
    });
});

此代码将添加一个标签和标题菜单父选项 。

< 强 > ORIGINAL

我不知道我是否理解你的问题是否正确, 但如果有帮助, 我更新了Khaled_webdevs Fiddle:http://jsfiddle.net/zQU7H/5

它一次显示一个子菜单, 如果显示另一个子菜单, 则更改它 。 在此示例中, 我做了第一个要显示子菜单元素的元素, 但是您可以删除这个元素, 并做任何您想要显示的子菜单, 首先是添加“ 流” 类 。

希望这能帮上忙

问题回答

i 添加了一个类当前值以模拟 Li 的活性链接

http://jsfiddle.net/zQU7H/2/" rel="no follow" >http://jsfiddle.net/zQU7H/2/

可能不是最终解决办法





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签