Difference between revisions of "Template:HKJS S/Javascript/Notebook"

Line 6: Line 6:
 
document.getElementById(a).style.display = "block";
 
document.getElementById(a).style.display = "block";
 
var b = a + "_btn";
 
var b = a + "_btn";
document.getElementById(b).innerHTML = "[Show]";
+
document.getElementById(b).innerHTML = "[Hide]";
 
}
 
}
 
}
 
}
Line 16: Line 16:
 
document.getElementById(a).style.display = "none";
 
document.getElementById(a).style.display = "none";
 
var b = a + "_btn";
 
var b = a + "_btn";
document.getElementById(b).innerHTML = "[Hide]";
+
document.getElementById(b).innerHTML = "[Show]";
 
}
 
}
 
}
 
}
 
function expand(value){
 
function expand(value){
 
var a = value + "_btn";
 
var a = value + "_btn";
 +
        var b = value;
 
var btn = document.getElementById(a)
 
var btn = document.getElementById(a)
 
if(btn.innerHTML == "[Show]"){
 
if(btn.innerHTML == "[Show]"){
document.getElementById(value).style.display = "block";
+
document.getElementById(b).style.display = "block";
 
document.getElementById(a).innerHTML = "[Hide]";
 
document.getElementById(a).innerHTML = "[Hide]";
 
}else{
 
}else{
document.getElementById(value).style.display = "none";
+
document.getElementById(b).style.display = "none";
 
document.getElementById(a).innerHTML = "[Show]";
 
document.getElementById(a).innerHTML = "[Show]";
 
}
 
}
 
}
 
}

Revision as of 12:15, 23 September 2018

function expandall(){ var value = ["229"]; var i; for (i = 0; i < value.length; i++){ var a = value[i]; document.getElementById(a).style.display = "block"; var b = a + "_btn"; document.getElementById(b).innerHTML = "[Hide]"; } } function collapseall(){ var value = ["229"]; var i; for (i = 0; i < value.length; i++){ var a = value[i]; document.getElementById(a).style.display = "none"; var b = a + "_btn"; document.getElementById(b).innerHTML = "[Show]"; } } function expand(value){ var a = value + "_btn";

       var b = value;

var btn = document.getElementById(a) if(btn.innerHTML == "[Show]"){ document.getElementById(b).style.display = "block"; document.getElementById(a).innerHTML = "[Hide]"; }else{ document.getElementById(b).style.display = "none"; document.getElementById(a).innerHTML = "[Show]"; } }