Answer the question
In order to leave comments, you need to log in
JavaScript: Why doesn't insertAdjacentHTML - afterEnd work?
Good afternoon!
Looping through the elements of an array:
tempImages.forEach(function(item, i, arr) {
var img = new Image();
// здесь собираю нужный мне img
// далее, мне необходимо обернуть элемент item (объект изображения) в ссылку
item.insertAdjacentHTML('beforeBegin', '<a href="' + href + '">');
item.outerHTML.insertAdjacentHTML('afterEnd', '</a>');
});
<a href="..."></a>
<img />
<a href="...">
<img />
</a>
item.outerHTML.insertAdjacentHTML('afterEnd', '</a>');
</a>
- after the current element? Answer the question
In order to leave comments, you need to log in
var anchor = document.createElement("a");
anchor.href = href;
anchor.appendChild(item);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question