在如下所示的XML节点中:

为什么这个代码不能工作?
xml = $.parseXML( xml );
console.log(xml);
plot = $(xml).find("movie");
aP = plot.attributes
console.log(aP);对于控制台日志,我正在变得没有定义。aP
我还尝试了aP = $(plot).attributes
发布于 2015-04-20 15:19:33
attributes不是jquery属性。通过这种方式尝试plot.get(0).attributes,您可以在元素上而不是在jquery对象上使用attributes属性。
$(xml).find("movie"); //returns jquery object
$(plot) // is a jquery object of a jquery object. You really want your object to be a jquery object aye?get(索引):Description:检索jQuery对象匹配的元素之一。
换句话说,get返回一个实际的元素。
https://stackoverflow.com/questions/29751852
复制相似问题