jquery - 为什么jquery hide在IE7中不能正常工作?

标签 jquery hide show-hide internet-explorer-7

我有一个包含不同 div 主体的弹出窗口,其中一个根据按下的按钮显示。 以下函数适用于 IE7:

function openPopup(popupDiv){
    //The popup is a div with id name popupDiv
    //It contains several bodies such as
    //alertPopupDiv, uploadPopupDiv, removePopupDiv
    //The div id name of the body to show is passed to the function

    //First hide all the bodies
    $("#popupDiv div[id$=PopupDiv]").each(function (i)
     {this.style.visibility='hidden';});  

    //Now show the relevant div
    var div = document.getElementById(popupDiv);
    if(div != null)
      {div.style.visibility = 'visible';}

   //Now call the function to load the popup itself          
   loadPopup();
}

但理想情况下我想使用更简单的:

function openPopup(popupDiv){
    $("div[id$=PopupDiv]").hide();  

    $(popupDiv).show();

   loadPopup();
}

这在 Firefox 和 IE8 中很好,但在 IE7 中不起作用(第一次调用它可以工作,但如果调用该函数使用新容器打开弹出窗口,则无法正确渲染。

最佳答案

使用内联或无属性

 $("#popupDiv div[id$=PopupDiv]").each(function (i)
         {this.style.display='none';});  

        //Now show the relevant div
        var div = document.getElementById(popupDiv);
        if(div != null)
          {div.style.display= 'inline';}

关于jquery - 为什么jquery hide在IE7中不能正常工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4827090/

相关文章:

ios - UISplitViewController 不会在横向模式下隐藏 masterViewController

android - 使用全屏隐藏 android 4.4+ 或 kitkat 中的状态栏

javascript - 同一页面性能问题上的多个推文按钮

jQuery(如果可见)

javascript - AJAX 请求触发两次,而成功被调用一次

jquery 条件可见性

android - 如何在 edittext + listview 布局中隐藏键盘

javascript - style.display 为 null - 尝试遍历数组并更改显示属性

jquery klout 隐藏名称值

javascript - 如何在文档就绪功能中使用 jQuery 动态隐藏 Bootstrap 3.3.4 中的下拉菜单?