Notes on js carousel

The carousel map is one of the functions that our beginners can write. Here, the author will talk about the problems that are prone to occur in the carousel map.

The first time I made a carousel image, I first let the image use the setInterval function to rotate the image, and then realized the subscript switching, the left and right button image switching, but the effect exists after completion, but there will be some small bugs when the left and right buttons switch , when you click for the first time, you will click twice to switch. The specific reason is that the author thinks that after the time function is executed once, it will immediately enter the next time, and the variable value recorded in the function has changed, so an error will occur.
The correct code flow should be to realize subscript switching first, switch left and right buttons, and then realize the carousel effect to perfectly complete the carousel image.

Guess you like

Origin blog.csdn.net/moanuan/article/details/103344295