开发者

Why does jquery hide not work properly in IE7?

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 开发者_Python百科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.


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';}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜