JQuery 绑定select标签的change事件,跳转网站

浏览:3777 发布日期:2017/03/02 分类:技术分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title> 
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script> 
<script> 
$(function(){ 
    $('.select1').change(function(){
        //alert($(this).children('option:selected').val()); 
        window.location.href= $(this).children('option:selected').val();
    })
}) 
</script> 
</head> 
<body> 
<select class="select1">
    <option value="http://www.baidu.com">百度</option>
    <option value="http://www.sohu.com">搜狐</option>
</select> 
</body> 
</html> 
最佳答案
评论() 相关
后面还有条评论,点击查看>>