本文介绍了document.getElementsByTagName在vbscript中工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  

因此 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中工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 13:16