http://jsfiddle.net/YaMhn/8/阿尔特标题标签的显示/隐藏的Javascript
^^^^看一看,看看你是否能帮助解决这个
行,所以我加了标签显示隐藏我的脚本
function showHide(lbl)
{
if(document.getElementById('mydiv').style.display == "none")
{
lbl.innerHTML="Hide";
document.getElementById('mydiv').style.display="";
}
else
{
lbl.innerHTML="Show";
document.getElementById('mydiv').style.display="none";
}
}
function showhide(id) {
if (document.getElementById) {
obj = document.getElementById(id);
if (obj.style.display == "") {
obj.style.display = "none";
} else {
obj.style.display = "";
}
}
}
function hide(id) {
if (document.getElementById) {
obj = document.getElementById(id);
if (obj.style.display == "none") {
obj.style.display = "none";
} else {
obj.style.display = "none";
}
}
}
function hideall(id1,id2,id3,id4) {
var status1 = document.getElementById(id1).style.display;
var status2 = document.getElementById(id2).style.display;
var status3 = document.getElementById(id3).style.display;
var status4 = document.getElementById(id4).style.display;
if ((status1 == 'none') || (status2 == 'none') || (status3 = 'none') || (status4 = 'none')) {
hide(id1); hide(id2); hide(id3); hide(id4); return;
}
if ((status1 != 'none') || (status2 != 'none') || (status3 != 'none') || (status4 != 'none')) {
hide(id1); hide(id2); hide(id3); hide(id4); return;
}
}
function show(id) {
if (document.getElementById) {
obj = document.getElementById(id);
if (obj.style.display == "") {
obj.style.display = "";
} else {
obj.style.display = "";
}
}
}
function showall(id1,id2,id3, id4) {
var status1 = document.getElementById(id1).style.display;
var status2 = document.getElementById(id2).style.display;
var status3 = document.getElementById(id3).style.display;
var status4 = document.getElementById(id4).style.display;
if ((status1 == 'none') || (status2 == 'none') || (status3 = 'none') || (status4 = 'none')) {
show(id1); show(id2); show(id3); show(id4); return;
}
if ((status1 != 'none') || (status2 != 'none') || (status3 != 'none') || (status4 != 'none')) {
show(id1); show(id2); show(id3); show(id4); return;
}
}
这里是我的头代码:
Header #1: (titled Runway Information Click to Expand/Close)
<div style="background-color:black; width:80%; cursor:pointer;hand" onClick="showhide('id1'); return(false);"><table width="100%"><tr><td width=80% align=left><font color="white" size="4"><strong> Runway Information</strong></font></td><td align=right><div id='mydiv' style='display:none'></div></td></tr></table></div>
页眉工作prefectly,表演和喜就像我编码一样。但我希望它在隐藏时显示“显示”,并在显示时显示“隐藏”。
以前它是这样写的: 点击展开/关闭
问题是,新的显示隐藏(LBL)为预期不起作用。
我需要改变什么?
所以......改变'innerHTML',有什么大不了的? – gdoron 2012-03-05 08:23:05