IE javascript problem with break or classname

I'm not sure if the problem is here, it works with chrome and ff, but not that.

var newdiv = document.createElement("div");
newdiv.innerHTML = xhr.responseText;
el = newdiv.firstChild.nextSibling;
var next;
do{
next = addpoint.nextSibling;
if(next.className != "commentstyle golduser") break;
}while(addpoint = next);
document.getElementById("testimonialcommentlisting"+id).insertBefore(el,next);

an error in this line document.getElementById ("testimonialcommenting" + id) .insertBefore (el, next);


**UPDATE**

OK, this is werid, I did some tests and I found the problem. the problem with var el for chrome and ff el is the div element, and ie is null.

a more complex problem arises here. In truth, newdiv.firstChild should be a div element, but I don't know why ff and chrome register it as a text element, and obviously my answer is Text is something like this

<div>blahblah</div>

I hope someone understands what I'm talking about.

+3
source share
1 answer

. addpoint.nextSibling, className , , , node. , , next null, className null.

while (next) {
    if (next.className != 'commentstyle golduser') break;
    next = next.nextSibling;
}

, , , addpoint. , addpoint, , , .

, next.className, next null.

+1

Source: https://habr.com/ru/post/1769035/


All Articles