使用< option>内的href链接标记以链接到URL [英] using href links inside <option> tag to link to url

查看:147
本文介绍了使用< option>内的href链接标记以链接到URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚下载了该主题的源代码

i just downloaded the source code from this topic

http://tympanus.net/codrops/2012/11/29/simple-effects-for-drop-down-lists/

演示 http://tympanus.net/Development/SimpleDropDownEffects/index6.html

并将其添加到我的项目之一中,并且工作正常,但我想添加链接作为值以链接到作为ahref的任何网站 我在其他主题中发现了一些东西,但是却无法与我合作,而且它的写作时间很长,所以我添加了这个主题

and added it to one of my project and works fine but i want to add links as values to link to any website as ahref i found some things to another topics but didn't work with me and it was written from long time so that i added this topic

<select id="cd-dropdown" name="cd-dropdown" class="cd-select">
   <option value="-1" selected>choose an option to test</option>
   <option value="1" class="icon-monkey">Students</option>
   <option value="2" class="icon-bear">Courses</option>
   <option value="3" class="icon-squirrel">Instructors</option>
   <option value="4" class="icon-elephant">Departments</option>                                 

推荐答案

尝试一下

 <select id="cd-dropdown" name="cd-dropdown" class="cd-select">
   <option value="-1" selected>choose an option to test</option>
   <option value="1" class="icon-monkey">Students</option>
   <option value="2" class="icon-bear">Courses</option>
   <option value="3" class="icon-squirrel">Instructors</option>
   <option value="4" class="icon-elephant">Departments</option> 
</select>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">

    jQuery('#cd-dropdown').on('change', function(){
        if(jQuery(this).val() == 1){
        window.location.href = 'http://google.com'
        }
        // and so on
        })
</script>

您必须为所有选项jQuery代码提供目标URL.

You have to give the destination URL for all options jQuery code.

这篇关于使用&lt; option&gt;内的href链接标记以链接到URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆