JavaScript css样式在IE中不起作用,它在Chrome和Mozilla中运行。
这是我的代码:
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%;}
请帮助。在此先感谢。
答案 0 :(得分:1)
试试这个
jQuery(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";
}
document.getElementById("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";
}
}
});