각 Control
의 (Controls[i]
) Click
에 스크립트가 Toggle
번 발생합니다. Control
최초 OL
소자 Visible
아닌 경우는 Visible
설정해야 현재 Control
(Controls[i]
)하지 Controls
다른 모든 요소 Hidden
설정되어야한다. Control
의 첫 번째 OL
요소가 Visible
인 경우 Hidden
으로 설정해야합니다.for 문에서 (그룹 내에서) 모든 요소의 가시성을 전환 할 수없는 이유는 그룹의 마지막 요소 만 토글됩니까?
의 .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++){
/* (function(){ */
if(Controls[i]!=Control){
Control.style.visibility="hidden";
}else{
Control.style.visibility="visible";
};
/* })(); */
};
}else{
Control.style.visibility="hidden";
};
};
function Event(Mode,Function,Event,Element,Capture_or_Bubble){
if(Mode.toLowerCase()!="remove"){
if(Element.addEventListener){
if(!Capture_or_Bubble){
Capture_or_Bubble=false;
}else{
if(Capture_or_Bubble.toLowerCase()!="true"){
Capture_or_Bubble=false;
}else{
Capture_or_Bubble=true;
};
};
Element.addEventListener(Event,Function,Capture_or_Bubble);
}else{
Element.attachEvent("on"+Event,Function);
};
};
};
function Controls(){
var Controls=document.getElementById("Quote_App").getElementsByTagName("dd");
for(var i=0;i<Controls.length;i++){
(function(){
var Control=Controls[i];
Event("add",function(){
Toggle(Control);
},"click",Control);
})();
};
};
Event("add",Controls,"load",window);
나는 그것이
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++){
/* (function(){ */
if(Controls[i]!=Control){
Control.style.visibility="hidden";
}else{
Control.style.visibility="visible";
};
/* })(); */
};
}else{
Control.style.visibility="hidden";
};
};
function Event(Mode,Function,Event,Element,Capture_or_Bubble){
if(Mode.toLowerCase()!="remove"){
if(Element.addEventListener){
if(!Capture_or_Bubble){
Capture_or_Bubble=false;
}else{
if(Capture_or_Bubble.toLowerCase()!="true"){
Capture_or_Bubble=false;
}else{
Capture_or_Bubble=true;
};
};
Element.addEventListener(Event,Function,Capture_or_Bubble);
}else{
Element.attachEvent("on"+Event,Function);
};
};
};
function Controls(){
var Controls=document.getElementById("Quote_App").getElementsByTagName("dd");
for(var i=0;i<Controls.length;i++){
(function(){
var Control=Controls[i];
Event("add",function(){
Toggle(Control);
},"click",Control);
})();
};
};
Event("add",Controls,"load",window);
For
문 뭔가 확신 소스에 당신은 내가 노력 클로저를 주석 한 볼 수 있지만 그 역시 작동하지 않았다. 나는 아직도 폐쇄에서 유능하지 않은 채로 시작하고있다.
감사합니다. 미리 감사드립니다.
내 역할에 대해 어리석은 감시가 있습니다. 나는 해결책을 찾기 위해 깊숙한 곳을 찾고 있었고 분명한 것은 바로 건너 뛰었습니다! –
Kudos Colin, 웹 사이트에서 2 분 안에 답변을 수락합니다! –