Making a simple javascript Image gallery

前端 未结 2 1162
臣服心动
臣服心动 2021-01-16 09:38

I\'m trying to make a very simple Image gallery. Most of the design is already complete (used JQuery)...but now I\'m trying to think out the logic it takes to get the images

2条回答
  •  半阙折子戏
    2021-01-16 10:29

    Most importantly, you need to build the background property by concatenating ("+" operator) its different parts, as shown below ; otherwise it won't be replaced by the values from your array if you make it a static string.

    Also use the global scope to declare and initialize your image array and counter :

    
    

    Finally, return false from onclick otherwise you'll reload the page :

    
    

提交回复
热议问题