我有一个包含不同 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/