style.display = 'none' 在 IE8 中有效,但在 IE11 中不起作用



我的系统在IE8上工作,现在这个客户想在windows7 + IE11上使用这个系统。这段代码的"风格"。Display = 'none' "不起作用。

<script language="JavaScript">
     function hide(){ 
        var type2=document.getElementsByName("type2"); 
        for(var i=0;i<type2.length;i++){
              type2[i].style.display="none"; 
         }
     } 
</script>
<table border="0" > 
     <tr> 
        <td nowrap align="left" id="type2">
             <bean:message bundle="ests" key="part"/>
        </td> 
       <td nowrap align="left" id="type2"><bean:message bundle="ests" key="ests.estRequest.label.businessKanriNo"/>
      </td> 
 	<td nowrap align="left" id="type2"><html:text maxlength="7" property="businessKanriNo" size="15" />&nbsp;
     </td> 
  </tr> 
</table>

 $('.btn').css('display','block','important');

或者你可以在css中使用它display:none !important

或者你可以在jquery中使用hide()来隐藏元素。这样的

 $(document).ready(function(){
  $('p').hide(); //if you wanna hide <p>
 }):

getElementsByName是导致这个问题使用getElementsById。它会解决你的问题。正确代码如下:

<script language="JavaScript">
     function hide(){ 
        var type2=document.getElementById("type2"); 
        for(var i=0;i<type2.length;i++){
              type2[i].style.display="none"; 
         }
     } 
</script>

你也可以使用jQuery属性来选择这个元素:

$("#type2").css("display", "none");

相关内容

最新更新