我有一個全局變量「isOnSecond」,它最初被設置爲falseJavaScript邏輯問題
這是連接到檢測布爾值if語句,如果這是真的有些動作被執行,然後布爾是設置回false。因此我希望這項行動能夠在一半時間內完成。
我的問題是這樣的,我知道我在這個函數中有邏輯問題,但是在這一點上我似乎無法想出一個解決方案。
我應該如何重新使用我想要的邏輯工作這個功能?
function transComplete()
{
slideTransStep = 0;
crtSlideIndex = nextSlideIndex;
alert(isOnSecond);
// for IE filters, removing filters re-enables cleartype
if (nextSlide.style.removeAttribute)
nextSlide.style.removeAttribute("filter");
// show next slide
showSlide((crtSlideIndex >= totalSlides) ? 1 : crtSlideIndex + 1);
if (isOnSecond == true){
//unhighlight all controls
for (var i=0; i < slidesControllersCollection.length; i++){
if (slidesControllersCollection[i].className === slideHighlightClass)
slidesControllersCollection[i].className = ""; }
// highlight the control for the next slide
if (slidesControllersCollection[i].className === slideHighlightClass)
document.getElementById("slide-control-" + crtSlideIndex+1).className = slideHighlightClass;
isOnSecond = false;
}
isOnSecond = true;
}
首先,我會建議將所有if語句包裝在'{}'中。但你總是在最後設置'isOnSecond'爲'true',所以這可能是問題 –
謝謝你們,得到它的工作,學校的男孩錯誤:) – user2696787
你需要_deperly_ indent你的代碼。問題應該是顯而易見的。 – SLaks