I am currently working on developing a toggle switch feature that can drain the color from an image when toggled. While following a tutorial to create this switch using CSS, I realized that it requires creating a new class name for each switch used, making it difficult to reuse the code efficiently. Is there a recommended JavaScript or jQuery solution that would allow me to use this toggle functionality multiple times?
The main issue I am facing is that whenever I click on any of the switches, only the first switch animates, leaving others unaffected.
<div class="switch">
<input id="cmn-toggle-7" class="cmn-toggle cmn-toggle-yes-no" type="checkbox">
<label for="cmn-toggle-7" data-on="Color" data-off="B&W"></label>
</div>