document.getElementsByTagName在vbscript中工作吗? [英] does document.getElementsByTagName work in vbscript?
问题描述
elems = document.getElementById(itemsTable ).getElementsByTagName(TR)
for j = 0 to ubound(elems) - 1
'stuff
next
好吧,那不会起作用,显然elems是一个对象,而不是像你在那个 javascript中看到的数组。尽管如此,我仍然坚持使用VBScript。
那么我该如何迭代vbscript中的表中的所有行呢?
编辑:是的,它是vbscript,它很糟糕。我在这里没有选择,所以不要说使用jQuery !!。
UBound()
不起作用。将它作为一个集合处理。 通过它进行Eaching应该可以工作:
Set NodeList = document.getElementById(itemsTable)。getElementsByTagName(TR)
For Each Elem In NodeList
'stuff
MsgBox Elem.innerHTML
Next
Well, it works, it just doesn't produce anything worthwhile:
elems = document.getElementById("itemsTable").getElementsByTagName("TR")
for j = 0 to ubound(elems) - 1
' stuff
next
Well, that won't work, apparently elems is an object, not an array like you'd get in that fancy javascript. I'm stuck with vbscript though.
So what do I do to iterate all the rows in a table in vbscript?
Edit: Yes, it's vbscript and it sucks. I don't have a choice here, so don't say "Use jQuery!!".
As you have correctly stated getElementsByTagName
does not return an array, hence UBound()
will not work on it. Treat it as a collection.
For-Eaching through it should work:
Set NodeList = document.getElementById("itemsTable").getElementsByTagName("TR")
For Each Elem In NodeList
' stuff
MsgBox Elem.innerHTML
Next
这篇关于document.getElementsByTagName在vbscript中工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!