有关
$.map(holder[i], function (elem, index) {
if (elem.nodeType === 1) {
var attr = "";
if (typeof elem.attributes !== 'undefined') {
attr = ' ' + elem.attributes[0].name + '=' + '"' + elem.attributes[0].nodeValue + '"';
}
return '<' + elem.nodeName + attr + '>' + elem.textContent + '</' + elem.nodeName + '>';
} else if (elem.nodeType === 3) {
return elem.textContent
}
});
其中holder [i]是通过
迭代XML获得的节点数组$('[btn-label =“'+ title +'”] flashtext',myXML).each(function(){ holder.push($(本).contents()得到()); });
为什么我会在IE7中收到错误“Object Required”?问题出在这里:
if (typeof elem.attributes !== 'undefined' )
答案 0 :(得分:0)
这是因为jQuery对象的attributes属性永远不会被定义,但是null
(例如文本节点),一个空数组(对于没有属性的标记,例如<strong>
)或一组关联数组。