簡體   English   中英

style.display = 'none' 適用於 IE8 但不適用於 IE11

[英]style.display = 'none' works in IE8 but not IE11

我的系統在 IE8 上運行,現在這個客戶想在 windows7 + IE11 上使用這個系統。 此代碼“style.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使用它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");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM