Answer the question
In order to leave comments, you need to log in
Question about javascript and outerHTML. Why is that?
Why in this example (i++) elements are replaced through one
plnkr.co/edit/5SDvtVa3pWmN7XgHjRL8?p=preview
and in this (i+1) everything is fine?
plnkr.co/edit/4WwtyObE8gXrMAg7jQpT?p=preview
Answer the question
In order to leave comments, you need to log in
I think I already explained to you here: Why doesn't replaceWith work?
var links = document.getElementsByClassName('link-span');
while(links.length) {
links[0].outerHTML = '<a target="_blank" href="#">New элемент</a>';
}
i+1
it does absolutely nothing with the variable - i
as it was 0, it will remain 0.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question