N
N
ne_pes2020-05-06 14:02:13
css
ne_pes, 2020-05-06 14:02:13

How to load an image when a tab is clicked?

There are tabs, when you click on them, an image appears. How can I make the image load only after clicking on the tab, and not all together when loading?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
PQR, 2020-05-06
@PQR

Modern versions of browsers support lazy loading of images if you add the loading="lazy" attribute to the img tag: More details: https://habr.com/ru/company/ruvds/blog/448914/
<img src="..." loading="lazy" />

A
Alexander Sharomet, 2020-05-06
@sharomet

$(таб).click(function(e) {
e.preventDefault();
$(контейнер куда нужно подгрузить картинку).append('<img src="'  путь к вашей картинке  '" alt="">');
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question