Why is jQuery not working properly in IE7?

I have a popup containing different div bodies that displays according to the pressed button. 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 like to use a lot easier:

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

    $(popupDiv).show();

   loadPopup();
}

Which is good in Firefox and IE8, but does not work in IE7 (it works the first time it is called, but if the function calls, a pop-up window with a new container does not appear properly.

+3
source share
1 answer

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';}
+2
source

Source: https://habr.com/ru/post/1788451/


All Articles