I have this code that doesn't work in FF due to a bug with the firstchild bit:
And I want to replace it with the below, but I'm not sure how or what I pass to the function?
Code:
var opts = obj.childNodes;
var li = document.createElement('li');
var txt = document.createTextNode(opts[0].firstChild.firstChild.nodeValue);
Code:
var opts = obj.childNodes;
var li = document.createElement('li');
var txt = document.createTextNode(opts[0].getFirstChild().getFirstChild().nodeValue);
Code:
function getFirstChild(elm){
if ( !elm.childNodes.length ){
return;
}
var children = elm.childNodes.length;
for ( var i = 0; i <= children; ++i ){
if ( elm.childNodes[i].nodeType == 1 ){
return elm.childNodes[i];
}
}
return;
}
Comment