不工作的JavaScript CSS样式不工作在IE,它是工作在浏览器和Mozilla。JavaScript的CSS样式在IE
这是我的代码:
document.ready=function() {
var val = document.getElementById("registration_select").value;
if(val =="Relay - Ultra, Standard and Sprint distances (Men/Women/ Mixed) - open to all Age-Groups & Juniors above 16"){
document.getElementById("register_right").style.display="block";
}
else{
document.getElementById("register_right").style.display="none";
}
registration_select.onchange=function(){
var val = document.getElementById("registration_select").value;
if(val =="Relay - Ultra, Standard and Sprint distances (Men/Women/ Mixed) - open to all Age-Groups & Juniors above 16"){
document.getElementById("register_right").style.display="block";
}
else{
document.getElementById("register_right").style.display="none";
}
}
};
这是我的HTML
<select id="registration_select" name="Category">
<option value="category1">category1</option>
<option value="Relay - Ultra, Standard and Sprint distances (Men/Women/ Mixed) - open to all Age-Groups & Juniors above 16">Relay - Ultra, Standard and Sprint distances (Men/Women/ Mixed) - open to all Age-Groups & Juniors above 16</option>
</select>
<div id="register_right">
<h3>Team Mate Profile</h3>
</div>
,这是我的CSS
#register_right{float:right; display:none; width:49%;}
请帮助。提前致谢。
PLZ显示HTML also..and确保没有重复的'id's'在你的HTML。 – 2014-10-01 05:14:32
在这里看不到任何jQuery。 – Cheery 2014-10-01 05:15:57
只是一个建议... javascript是区分大小写的,你正在比较长状态字符串,如果statememt ...所以只要将左侧和右侧转换为小写,然后检查它们是否相等。 – 2014-10-01 05:20:00