http://css-tricks.com/convert-menu-to-dropdown” rel=“nofollow”http://csss-tricks.com/convert-menu-to-dropdown。 这对于将标准导航转换成“门努”选择具有很大作用。 我很想知道,如何增加同子公司合作的条件。 举例来说,这里是“WordPress”导航造成......违约。
<ul id= menu-collections >
<li><a href= http://... >blah</a>
<ul class= sub-menu >
<li><a href= http://... >blah</a></li>
</ul>
</li>
</ul>
http://jsfiddle.net/eaDLX/"rel=“nofollow” http://jsfiddle.net/eaDLX/。
What I would like to do is prepend - to each ul that has a class of sub-menu so that my list looks like this...
选择......
Editorial (this would be the parent)
-- 1920s Collection (this would be the child)
广告
-- Baulmer Collection
......
我确信,这样做非常简单,但我无法作出合乎逻辑的飞跃。 谁能帮助? 成就
// Create the dropdown base
$("<select />").appendTo("nav#menu-collections");
// Create default option "Go to..."
$("<option />", {
"selected": "selected",
"value" : "",
"text" : "Choose a Collection..."
}).appendTo("nav#menu-collections select");
// Populate dropdown with menu items
$("nav#menu-collections a").each(function() {
var el = $(this);
$("<option />", {
"value" : el.attr("href"),
"text" : el.text()
}).appendTo("nav#menu-collections select");
});
$("nav#menu-collections select").change(function() {
window.location = $(this).find("option:selected").val();
});
/* Hide existing menu */
$( nav#menu-collections ul ).hide();