Answer the question
In order to leave comments, you need to log in
How to change source srcset on button click?
There is an image on the site inserted like this:
<picture>
<source srcset="img/cat-before-desktop.png" media="(min-width: 1440px)">
<source srcset="img/cat-before-table.png" media="(min-width: 768px)">
<img class="example__before" src="img/cat-before-mobile.png" alt="Толстый кот">
</picture>
Answer the question
In order to leave comments, you need to log in
Change when clicking on the button not only the value of img.src, but also source.srcset.
https://developer.mozilla.org/en/docs/Web/API/Elem...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question