jQuery - CSS DropDown 导航项 - 如何构建 Carrot 下拉菜单
我有兴趣学习一种智能、优雅的方法来在整个网站中构建导航项,这些导航项具有单击时会展开菜单项列表的胡萝卜。
我希望菜单项能够动态构建(不一定全部使用ajax)。但它们不应该在页面上硬编码。
这似乎就是像 TWITTER 这样的网站处理下拉菜单的方式......
例如在 Twitter 上,它们有:“Retweets \/”,当您单击胡萝卜时,它会在页面中注入以下内容:
<ul class="drop-down" style="left: 0px; right: auto; top: 31px; visibility: visible; ">
<li class="stream-link" data-item-id="">
<a title="Retweets by others" href="/#!/retweets_by_others">
<b class="item-name">
Retweets by others
</b>
</a>
</li><li class="stream-link" data-item-id="">
<a title="Retweets by you" href="/#!/retweets">
<b class="item-name">
Retweets by you
</b>
</a>
</li><li class="stream-link" data-item-id="">
<a title="Your Tweets, retweeted" href="/#!/retweeted_of_mine">
<b class="item-name">
Your Tweets, retweeted
</b>
</a>
</li>
</ul>
有关如何完成此操作的建议?
谢谢
I'm interested in learning the smart, elegant way to build navigation items throughout a site that have the carrot that when clicked expands a list of menu items.
I would like for the menu items to be built dynamically (not necessarily all with ajax). But they shouldn't be hard coded on the page.
That appears to be how sites like TWITTER handle the dropdown...
For example on Twitter they have: "Retweets \/" when you click the carrot, it then injects the following into the page:
<ul class="drop-down" style="left: 0px; right: auto; top: 31px; visibility: visible; ">
<li class="stream-link" data-item-id="">
<a title="Retweets by others" href="/#!/retweets_by_others">
<b class="item-name">
Retweets by others
</b>
</a>
</li><li class="stream-link" data-item-id="">
<a title="Retweets by you" href="/#!/retweets">
<b class="item-name">
Retweets by you
</b>
</a>
</li><li class="stream-link" data-item-id="">
<a title="Your Tweets, retweeted" href="/#!/retweeted_of_mine">
<b class="item-name">
Your Tweets, retweeted
</b>
</a>
</li>
</ul>
Suggestions on how to accomplish this?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你的 html 看起来像这样:
if your html looks like this: