using href links inside

2019-08-23 06:34发布

i just downloaded the source code from this topic

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

demo http://tympanus.net/Development/SimpleDropDownEffects/index6.html

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>                                 

3条回答
兄弟一词,经得起流年.
2楼-- · 2019-08-23 06:54

Try this

$('#cd-dropdown').on('change', function(){
var value = $(this).val();
if(value == 1){ // that is for Students
window.location.href = 'http://google.com';
}
// and so on
})
查看更多
聊天终结者
3楼-- · 2019-08-23 07:05

Try This

$('.cd-dropdown li').click(function(){
  if($(this).attr('data-value')==1){
    window.location.href = 'http://google.com';
  }

})

The plugin replaces select box [id=cd-dropdown] with ul [class=cd-dropdown]

查看更多
走好不送
4楼-- · 2019-08-23 07:07

Try this

 <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>

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

查看更多
登录 后发表回答