日期:2014-05-16  浏览次数:20461 次

为什么在select处添加onchange事件无效??
本帖最后由 dengjiejie1990 于 2013-05-26 23:57:29 编辑

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>图片+JavaScript+CSS打造漂亮的select下拉选择框
 - www.webdm.cn</title>
<style type="text/css">
body{margin:20px auto;font-family:Arial,Helvetica,sans-serif;font-size:12px;width:950px;height:400px;border:solid 1px #aaa;position:relative;padding:10px;}
h1{font-size:12px;color:#444;}
ul{margin:0;padding:0;list-style:none;}
.dropDownList{position:absolute;left:100px;top:100px;}
.dropDownList div.dropdown{float:left;margin-right:120px;}
.dropDownList span{display:block;width:146px;height:26px;background:url(http://www.webdm.cn/images/20100411/selectbg.gif) left top no-repeat;line-height:26px;text-indent:12px;border:solid 1px #83BBD9;cursor:default;}
.dropDownList span.over{background-position:left bottom;border-color:#B4C91A;}
.dropDownList ul{width:200px;display:none;position:absolute;}
.dropDownList ul li{background:#eee;height:20px;width:100%;padding:3px 0;text-indent:12px;cursor:default;line-height:20px;}
/*普通状态下的样式*/
.dropDownList ul li.normal{background:#eee;}
/*鼠标移上的样式*/
.dropDownList ul li.over{background:#ccc;}
/*被选中的样式*/
.dropDownList ul li.current{background:#c2c2c2;font-weight:bold;}
.dropDownList ul.show{display:block;}
</style>
 
</head>
<body>
<form action="#" method="get">
<div class="dropDownList">
<div id="dropDownList1" class="dropdown">
<select name="birthday" style="display: none">
<option>请选择</option>
<option>1986</option>
<option>1987</option>
<option selected="selected" onchange="javascript:alert('aaaaa')">1988</option>
<option>1989</option>
<option>1990</option>
</select>
<span>请选择年份</span>
<ul></ul>
</div>
<div id="dropDownList2" class="dropdown">
<select name="sex"  style="display: none">
<option>性别</option>
<option>男</option>
<option selected="selected">女</option>
<option>不是男,也不是女</option>
</select>
<span>请选择性别</span>
<ul></ul>
</div>
<div id="dropDownList3" class="dropdown">
<select name="student"  style="display: none">
<option>aaa</option>
<option>小学</option>
<option selected="selected">初中</option>
<option>高中</option>
</select>
<span>请选择学历</span>
<ul></ul>
</div>
</div>
</form>
<script type="text/javascript">
    var ____configArray;
    function __initDropDownList(configArray) {
        //获取Select菜单
        ____configArray = configArray;
        var existArray = configArray.split("|");
        for (var i = 0; i < existArray.length; i++) {
            if (existArray[i].length < 1) {&n