javascript – How to change a group of picture with a single click


You can do something like this with JavaScript:

  1. Add an event listener for Oat Milk and Cacao onClick event
  2. When the user clicks:
    1. Remove all images from the DOM
    2. Create 6 image elements and append them to the body

Googling parts of this answer might help you.

Alternatively, you can consider using React/Angular/Vue that will let you conditionally render images based on the current selection. It’ll be a cleaner, but a bit more complex solution.



Source link

Latest articles

Related articles

Leave a reply

Please enter your comment!
Please enter your name here