课程: Code Clinic: JavaScript

今天就学习课程吧!

今天就开通帐号,24,600 门业界名师课程任您挑!

Navigating through solutions

Navigating through solutions

- [Instructor] All right, so the last thing we need to do is make sure that these buttons allow us to advance and move back through our solutions. So to do that I'm going to move right here and do some ducument queryselector queries. We'll do the Previous button first. And we will add an event listener. Of course we're gonna be looking for a click. And then call a function that will pass along an event. We'll decrement the current solution and then if the solution is less than one, so if we click and it's already at the first position we will reset it so that it's at the index of the last position. Minus one because arrays are zero indexed, so this means the last one. And it looks like I need a parentheses right there. All right, so then we will need to clear the board with the clear the board function we created earlier and then we will need to actually load up the new board. And then finally we'll display the current solution here. All right, so let's see if that works. If we click…

内容