Press left and right arrow to change image?

后端 未结 3 1583
庸人自扰
庸人自扰 2021-01-03 10:14

So I have this simple slideshow:

\"slideshow\"
3条回答
  •  执念已碎
    2021-01-03 10:51

    See the answer in action http://jsfiddle.net/7LhLsh7L/ (note for fiddler: as it runs in editor itself before pressing arrow(left, right) keys, you should give focus(just click result area) to result area)

    Here is the markup and script:

    slideshow

    The features of above solution:

    • If you click on the image, it'll take you to next image and repeats the cycle when it reaches last image.
    • For Left arrow(<-) it loads previous image and cycles repeats in reverse direction when reaches first image.
    • Right arrow(->) behavior is similar to click.

提交回复
热议问题