Add image-switcher to toggle on action.
- No localStorage, only DOM
npm i image-switcher
- Load
image-switcher.min.js
at the foot of your page:
<script src="image-switcher.js"></script>
- Add ID to your image switch action:
<a href="#" id="image-switcher-action">
Switch image
</a>
- Add image sources and class to your image tag to switch:
<img class="image-switcher" src="images/1232.jpg" data-switch-src="images/1266.jpg">
- Add animation on images from animate.style:
<a href="#" class="image-switch-animation" id="image-switcher-action">
Switch image
</a>
<img class="image-switcher" src="images/1232.jpg" data-switch-src="images/1266.jpg" data-animation="bounce">