I am trying to add an image on top of multiple divs when the user clicks a button.
so
----------
| |
----------
----------
| |
----------
----------
| |
----------
----------
| |
----------
button
after click a button
oo means image
----------
|oo |
----------
----------
| |
----------
----------
|oo |
----------
----------
| |
----------
I am not sure how to accomplish this. Any hints would be appreciated. Thanks.
I’m going to go with a different assumption than “every other one”. Here’s a jsfiddle for demonstration
This solution allows for any arbitrary divs to gain an image upon button click, so long as you’ve identified them or tagged them in some way. So…
If your DOM identified which elements should gain a picture through some class naming:
And with some CSS like follows:
All you need is a function like so: