Сообщение от voraa
|
Примерно так это делается
const images = document.querySelectorAll('div.content img');
for (let i = 0; i < images.length; i++) {
const imgf = images[i];
const arri = [imgf];
let img = imgf.nextElementSibling;
while (img?.tagName === 'IMG') {
arri.push(img);
img = img.nextElementSibling;
i++;
}
if (arri.length > 1) {
const gal = document.createElement('div')
gal.className = 'gal';
imgf.parentElement.replaceChild(gal, imgf);
gal.append(...arri)
}
}
|
<div class="col-12 text">
<img data-src="/uploads/posts/2021-11/1636154460_default-good-1.png" class="fr-fic fr-dii lazy-loaded" alt="" src="/uploads/posts/2021-11/1636154460_default-good-1.png">
<img data-src="/uploads/posts/2021-11/1636154460_default-good-1.png" class="fr-fic fr-dii lazy-loaded" alt="" src="/uploads/posts/2021-11/1636154460_default-good-1.png">
<img data-src="/uploads/posts/2021-11/1636154460_default-good-1.png" class="fr-fic fr-dii lazy-loaded" alt="" src="/uploads/posts/2021-11/1636154460_default-good-1.png">
test test
<img data-src="/uploads/posts/2021-11/1636154460_default-good-1.png" class="fr-fic fr-dii lazy-loaded" alt="" src="/uploads/posts/2021-11/1636154460_default-good-1.png">
<img data-src="/uploads/posts/2021-11/1636154460_default-good-1.png" class="fr-fic fr-dii lazy-loaded" alt="" src="/uploads/posts/2021-11/1636154460_default-good-1.png">
</div>
вот такой текст был, класс контейнера с .content на .text в начале менял.