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

发布于 2024-10-15 06:34:19 字数 925 浏览 7 评论 0原文

我有一个包含不同 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 中不起作用(它第一次被调用时有效,但如果该函数被调用 open使用新容器的弹出窗口,无法正确渲染。

I have a popup containing different div bodies, one which shows according to button pressed.
The function below works in 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();
}

But ideally I would have like to use the much simpler:

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

    $(popupDiv).show();

   loadPopup();
}

Which is fine in Firefox and IE8, but doesn't work in IE7 (it works first time it is called, but if the function is calls open the popup with a new container, it fails to render properly.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

东走西顾 2024-10-22 06:34:19

使用内联或无属性

 $("#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';}

use inline or none property

 $("#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';}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文