Answer the question
In order to leave comments, you need to log in
How to wrap an image with the desired code?
Construction in progress:
<div class="news-full-text">
текст
<img src="#" свойств и тд>
текст
<img src="#" свойств и тд>
текст
</div>
<div class="image">
<img src="картинка">
<div class="image-social">социальные кнопки</div>
</div>
Answer the question
In order to leave comments, you need to log in
$('.news-full-text img')
.wrap('<div class="image"></div>')
.after('<div class="image-social">социальные кнопки</div>');
$('.news-full-text img').replaceWith(function() {
return `
<div class="image">
${this.outerHTML}
<div class="image-social">социальные кнопки</div>
</div>`;
});
$('.news-full-text').html((i, html) => html.replace(/<img .*?>/g, m => `
<div class="image">
${m}
<div class="image-social">социальные кнопки</div>
</div>
`));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question