이 return activePane
을 말한다 모두 잊어 버려. 작동하지 않습니다.
선택기를 재구성하는 것이 좋습니다. 사용할 선택자는 $("#slider .box .panel:visible")
입니다. 이렇게하면 각 루프가 완전히 끊어집니다. 다음과 같은 예를 들어 당신은 코드를 재구성 수 :
function checkPanes() {
return $("#slider .box .panel:visible").index();
}
function exampleCase() {
var visiblePane = checkPanes();
// ... do something with the index
}
난 그냥 선택기를 사용하여 인라인보다는 새로운 기능을 제안 싶지만, 그건 당신이 같은 선택해야 특히, 취향의 문제이다 여러 곳에서.
function checkPanes() {
activePane = '';
var panels = $("#slider .box .panel");
//create a return array
visiblePanels = [];
panels.each(function() {
//find the one in visible state.
if ($(this).is(":visible")) {
activePane = $(this).index()+1;
//add the result to the returnb array
visiblePanels[] = activePane
}
});
// return results
return visiblePanels;
}
function exampleCase() {
var thepane = checkPanes();
//now it has all the visible panels that were founded in the other function
// you can access them with thepane[0] or iterate on them
}
나는 이것이 당신이 필요하다고 생각 :
'return activePane;'시도해 보셨습니까? – Sampson