그것이 Visible
Visible
설정해야하고 다른 모든 Controls
(Controls[i]
) 아니다 Control
(Toggle
최초 OL
가 trigers 소자)가 그렇게 될 경우 Hidden
.else 절이없는 if 문보다 더 훌륭한 해결책이 있습니까? 다음 코드
의 .js function Toggle(Control){
var Controls=document.getElementsByTagName("ol",document.getElementById("Quote_App"));
var Control=Control.getElementsByTagName("ol")[0];
if(Control.style.visibility!="visible"){
for(var i=0;i<Controls.length;i++){
if(Controls[i]!=Control){
Reveal("hide",20,0.3,Controls[i]);
}else{
Reveal("show",20,0.3,Control);
};
};
}else{
Reveal("hide",20,0.3,Control);
};
};
function Toggle(Control){
var Controls=document.getElementsByTagName("ol",document.getElementById("Quote_App"));
var Control=Control.getElementsByTagName("ol")[0];
if(Control.style.visibility!="visible"){
for(var i=0;i<Controls.length;i++){
if(Controls[i]!=Control){
Reveal("hide",20,0.3,Controls[i]);
}else{
Reveal("show",20,0.3,Control);
};
};
}else{
Reveal("hide",20,0.3,Control);
};
};
함수 [Toggle
] 잘 작동하지만
Hidden
Controls[i]
에 설정된다.
이 코드는 아래 코드와 같이 If
문을 쉽게 추가 할 수 있습니다. 더 좋은 해결책이 있습니까? 아마도 If
이라는 복잡한 조건일까요?
의 .js function Toggle(Control){
var Controls=document.getElementsByTagName("ol",document.getElementById("Quote_App"));
var Control=Control.getElementsByTagName("ol")[0];
if(Control.style.visibility!="visible"){
for(var i=0;i<Controls.length;i++){
if(Controls[i]!=Control){
if(Controls[i].style.visibility=="visible"){
Reveal("hide",20,0.3,Controls[i]);
};
}else{
Reveal("show",20,0.3,Control);
};
};
}else{
Reveal("hide",20,0.3,Control);
};
};
function Toggle(Control){
var Controls=document.getElementsByTagName("ol",document.getElementById("Quote_App"));
var Control=Control.getElementsByTagName("ol")[0];
if(Control.style.visibility!="visible"){
for(var i=0;i<Controls.length;i++){
if(Controls[i]!=Control){
if(Controls[i].style.visibility=="visible"){
Reveal("hide",20,0.3,Controls[i]);
};
}else{
Reveal("show",20,0.3,Control);
};
};
}else{
Reveal("hide",20,0.3,Control);
};
};
당신의 도움이
항상 감사합니다.
버그 :
이러한 방법은 개별적인 요소에 속성을 적용 요소 목록에 속성을 적용하고있는 NodeList 배열? Control.getElementsByTagName ("ol") [0]; Controls.getElementsByTagName ("ol") [0]이어야합니다. ? – gregmac
버그가 없습니다. Toggle의 인수 Control은 Toggle을 트리거 한 요소입니다. Control 변수는 Control의 첫 번째 자식 OL (Control 인수의 옵션)입니다. –