JavaScript:迭代 document.evaluate() XPathResult 返回 null [英] JavaScript: iterating over document.evaluate() XPathResult returns null

查看:50
本文介绍了JavaScript:迭代 document.evaluate() XPathResult 返回 null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取所有对象,但它不起作用.

I am trying to get all objects but it doesn't work.

var tmp = document.evaluate("//tr", document, null, XPathResult.ANY_TYPE, null);

tmp.iterateNext 返回空值;

推荐答案

如果您在 IE 中工作,那么您应该知道 document.evaluate 在那里不存在(请参阅 这个类似的问题这里的最后几段).

If you are working in IE, then you should know that document.evaluate does not exist there (see this similar question and the last couple of paragraphs here).

为什么不只是 document.getElementsByTagName("tr");?

这篇关于JavaScript:迭代 document.evaluate() XPathResult 返回 null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆