My question:
Why is this condition being ignored in IE 8?
if (dynCheck[0].innerHTML == 'Empty' || dynCheck[0].innerHTML == "")` {continue}
More details:
I have a loop that is storing an array of list items into another array. I have a condition that checks if the first list item has a value of “Empty” if it does then continue. For some reason IE8 is ignoring this condition. Could it be because I’m checking against an Array holding a value?
Here is the entire loop:
for(var dynEl = 1; dynEl <= dynLists; dynEl++) {
//Get Array of List Items
var dynCheck = document.getElementById('loc' + dynEl).getElementsByTagName('li');
//Check if it is empty or not
if (dynCheck[0].innerHTML == 'Empty' || dynCheck[0].innerHTML == "") {continue}
//If there is content then add it to the Array
dynElArr[dynElIndx] = dynCheck;
//Increment Index
dynElIndx++;
}
Thank you!
innerHTMLis not necessarily the same between browsers, especially in regards to whitespace between nodes.Case 1:
Case 2:
May give different results.
Try
.nodeValueor select the actual textnode first and use.textContent/.nodevalue