gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 01:29:08 24 4
gpt4 key购买 nike

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com