选择选项,带锚点

时间:2012-04-25 04:19:19

标签: html

如何将以下代码转换为<select> <option>下拉列表?目前,当我选择下面的任何一个链接时,它会过滤掉仅显示所选项目的列表。

<span>Filters:</span>
<a class="button" href="#all">All</a>
<a class="button" href="#settings">Settings</a>
<a class="button" href="#categories">Categories</a>

尝试做类似的事情

<select>
<option class="button" href="#all">All</option>
<option class="button" href="#settings">Settings</option>
<option class="button" href="#categories">Categories</option>
...

3 个答案:

答案 0 :(得分:1)

jQuery的.change()可以帮助你。

http://api.jquery.com/change/

答案 1 :(得分:1)

为什么不在你的选项元素中添加onClick事件?

只需将location.href设置为每次onclick内所需的值。

答案 2 :(得分:1)

如果我理解正确,您希望链接的行为类似于选择框。 http://jsfiddle.net/aatZJ/1/