2014-10-01 6 views
0

JavaScript css стиль не работает в IE, он работает в Chrome и 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%;} 

Пожалуйста, помогите. Заранее спасибо.

+0

плз показать HTML also..and убедитесь, что нет дубликатов 'id's' в вашем HTML. –

+6

Не видите jquery здесь. – Cheery

+1

просто предложение ... javascript чувствителен к регистру, вы компилируете длинную строку в if statememt ... поэтому просто конвертируйте левую и правую сторону в нижний регистр, а затем проверьте, равны они или нет. –

ответ

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"; 
       } 
      } 

    }); 
+0

Спасибо Shaharan. Это сработало :) –

+0

@AasimHussainKhan: в вашем коде регистрация_select не была определена. – shaharan

Смежные вопросы