Hi,
I'm trying to change this if statement to a switch like this:
Before
AfterCode:if ($(this).attr('id') === 'right') { if (tabindex === slides) { tabindex = 1; move = '+=' + windowWidth * (slides - 1); } else { tabindex += 1; move = '-=' + windowWidth; } } else { if (tabindex === 1) { tabindex = slides; move = '-=' + windowWidth * (slides - 1); } else { tabindex -= 1; move = '+=' + windowWidth; } }
But the result is not the same.Code:if ($(this).attr('id') === 'right') { switch (tabindex) { case (tabindex === slides): tabindex = 1; move = '+=' + windowWidth * (slides - 1); break; default: tabindex += 1; move = '-=' + windowWidth; } } else { switch (tabindex) { case (tabindex === 1): tabindex = slides; move = '-=' + windowWidth * (slides - 1); break; default: tabindex -= 1; move = '+=' + windowWidth; }
What am I doing wrong? What is the right solution?
Thanks



Reply With Quote

Bookmarks