创建使用显示/隐藏图层和 Z 索引更改页面内容的下拉菜单
我正在尝试为网站创建一个侧边栏,允许用户从下拉菜单中选择一个项目并显示 RSS 源。 提要将根据从列表中选择的项目而变化。 我不知道如何完成这个,但我的第一个想法是使用 z-index 和显示/隐藏图层。 我设置了一层和菜单,但它不允许我更改选择不同菜单项时显示的提要。 有谁知道我怎样才能做到这一点?
我可以实时预览到目前为止我已完成的工作。 它位于网站 CHUD 上,
I am trying to create a sidebar for a site that will allow a user to select an item from a drop down menu and show an RSS Feed. The feed will change depending on which item is selected from the list. I am not sure how to acomplish this, but my first thought was to use z-index and show/hide layers. I have one layer and the menu set up, but it will not allow me to change the feed displayed when a different menu item is selected. Does anyone know how I can acomplish this?
I have a live preview up of what I have gotten done so far. It's located on the site, CHUD,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它使用 jQuery 和 jFeed 插件根据下拉选择替换 DIV 的内容。
超文本标记语言
This uses jQuery and jFeed plugin to replace the contents of a DIV based on a dropdown selection.
HTML
这并不完全相同,但它使用简单的 CSS 和 HTML,不需要 Javascript。
一些逆向工程可以大有帮助。
Image_switcher
它是荷兰语,但很简单:将鼠标移到
上
部件和图像开关。纯CSS+HTML,无Javascript
It's not exactly the same thing, but this uses simple CSS and HTML and no Javascript needed.
A bit of reverse engineering can go a long way.
Image_switcher
it's in dutch, but it's simple: move your mouse over the
<a>
parts and the image switches.Pure CSS+HTML, no Javascript
您有两个选择:
预加载所有 RSS 提要(我假设示例页面中的
是 RSS 提要的 HTML 输出?)、隐藏加载文档时将它们全部显示出来,然后将它们显示为选定的
在选择框更改时使用 AJAX 动态抓取所选的提要信息。
下面是执行前者的 javascript 和 jQuery 版本的简单示例:
html:
javascript:
jQuery:
要执行选项 2,您的
onchange
函数将处理 AJAX 加载。 如果您不太熟悉 AJAX,并且有一些提要,那么选项 1 可能是最简单的。 (再次,我假设您已经将 RSS 解析为 HTML,因为这完全是另一个主题)。you have two options:
pre-load all the rss feeds (i'm assuming your
<ul>
's in your example page are the HTML output of your RSS feeds?), hide them all when your document loads, and then reveal them as selecteduse AJAX to dynamically grab the selected feed information as your select box changes.
here's a quick example of a javascript and jQuery version of doing the former:
html:
javascript:
jQuery:
to do option 2, your
onchange
function would handle the AJAX loading. if you're not that familiar with AJAX, and have a few feeds, option 1 is probably the easiest. (again, i'm assuming you have already parsed out your RSS as HTML, as that's another topic altogether).