21 lines
526 B
JavaScript
21 lines
526 B
JavaScript
function hide(id) {
|
|
var els = document.getElementsByClassName("on");
|
|
[].forEach.call(els, function (el){
|
|
console.log(el.id);
|
|
console.log(id);
|
|
console.log(id.substr(0, el.id.length));
|
|
console.log(id.substr(0, el.id.length) != el.id);
|
|
if (el.id != id.substr(0, el.id.length)) {
|
|
el.className = "off";
|
|
}
|
|
});
|
|
}
|
|
|
|
function display(id) {
|
|
hide(id.toString());
|
|
var el = document.getElementById(id);
|
|
if (el!=null) {
|
|
el.className = "on";
|
|
}
|
|
}
|