我有两个 div,一个的显示属性默认是块,另一个是无。当您单击一个按钮时,显示会切换,因此一个隐藏而另一个显示。它适用于除 IE 之外的所有浏览器。知道为什么会这样吗?是不是和IE的innerHTML问题有关?我将粘贴js和html
JavaScript:
function show(id, elm){
var hide = document.getElementById(id);
var show;
var closeIcon = document.getElementById("closeIcon");
if(id.substring(0, 3) != "set"){
elmName = "set"+id.substring(0, 1).toUpperCase() + id.substring(1, id.length);
if(id != "video") hide.style.display = "none";
show = document.getElementById(elmName);
show.style.display = "block";
$("#instruccionBox").hide();
$("#flechaEdit").hide();
}else{
elmName = id.substring(3, 4).toLowerCase() + id.substring(4, id.length);
hide.style.display = "none";
show = document.getElementById(elmName);
show.style.display = "block";
$("#instruccionBox").show();
$("#flechaEdit").show();
skipStep();
}
if(id.substring(0, 3) != "set" && id != "meta" && id != "fechaLimite"){
$('#closeIcon').show();
closeIcon.style.left = $(show).width() - 45 + "px";
closeIcon.style.top = "0px";
show.appendChild(closeIcon); //alert(show.id);
}
}
HTML:
<div class="grid_4 proyectoDonaciones" id="meta">
<img src="images/edit-icon.png" alt="" class="editIcon" style="position:absolute; display:none" id="editMeta" onclick="show('meta')"/>
<h1 class="letter border1-pad2">META</h1>
<!--div class="triangulo_izq_claro"></div-->
<div>
<img src="images/cabezaIguana.png" alt="" width="70" class="editIcon" style="position:relative; left:12px;" onclick="show('meta')" id="cabezaMeta"/>
<div class="donacionesBarra">
<div style="margin:0 0 -60px 40%;"><h2 id="porcentajeMeta">0%<h2></div>
<table width="100%">
<tr height="45">
<td id="metaLeft" bgcolor="#a4c547" width="0%"></td>
<td id="metaRight" bgcolor="#FFFFFF" width="100%"></td>
<td><img src="images/colaIguana.png" alt="" width="70" style="position:absolute; left:250px;"/></td>
</tr>
<tr>
<td colspan="2"><span style="float:right;"><h3 style="color:#839e38;">$</h3></span></td>
</tr>
<tr>
<td colspan="2"><span style="float:right; font-size:15px;">of $<span id="metaText">9000</span> Goal</span></td>
</tr>
</table>
</div>
</div>
</div>
<div class="grid_4 proyectoDonaciones" style="margin-top:10px; display:none;" id="setMeta">
<h2 style="margin:10px;">Escriba la meta</h2>
<div style="margin:10px 25px 10px 10px;">
<input type="text" id="inputMeta" value="9000" style="width:100%;" class="pro_form2" / >
<br />
<center>
<input type="button" value="ACTUALIZAR" class="pro_btn pro_warning" onclick="show('setMeta', document.getElementById('closeIcon'))" />
</center>
</div>
</div>