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

怎么解决jquery与IE不兼容?
代码:function change_type(t){
if(t==1){
$("#select_1").show();
$("#select_2").hide();
$("#select_3").hide();
}
else if(t==2){
$("#select_1").hide();
$("#select_2").show();
$("#select_3").hide();
}else if(t==3){
$("#select_1").hide();
$("#select_2").hide();
$("#select_3").show();
}  
}

页面上:
<form action="repair_find.action" method="post" style="padding-top:5px;">
按:<select name="selectre" id="selectre">
  <option value="repairsid" selected="selected" onclick="change_type(1)">报修单ID</option>
  <option value="faultty" onclick="change_type(2)">故障类型</option>
  <option value="repairsst" onclick="change_type(3)">报修单状态</option>
</select>&nbsp;
<input type="text" name="reid" style="width:70px" id="select_1"/>

<select name="ids" id="select_2">
  <c:forEach items="${faultTypes}" var="faultType">
<option value="${faultType.id}" >${faultType.ft_name}</option>
</c:forEach>
</select>
<select name="states" id="select_3">
  <c:forEach items="${repairsStates}" var="repairsState">
<option value="${repairsState.id}">${repairsState.state_desc}</option>
</c:forEach>
</select>

<input type="submit" value="查询"/>
</form>

在火狐上和IE9上没问题 但是IE6 7 8 就是不行 怎么解决呢???

------解决方案--------------------
和jq没关系,是你事件用错了,option在IE6~8没有click事件,给select加onchange事件就好了

HTML code
<select name="selectre" id="selectre" onchange="change_type(this.selectedIndex+1)">
  <option value="repairsid" selected="selected">报修单ID</option>
  <option value="faultty">故障类型</option>
  <option value="repairsst">报修单状态</option>
</select>