我一直在搜索整个论坛、msdn 和专业教程,但找不到 VBA 的答案:
我怎样才能使getElementById
在访问 VBA 模块中工作,其中要查找的 id 是动态的?
我们看一下html代码:
<DIV id=rowToolTipContainer>
<DIV class=contactsCard id=resultsTooltip1122286Contents style="DISPLAY: none">
<TABLE class="shadow-box tooltip">
<TBODY>
以及我如何尝试找到它:
Dim ResultDIV As HTMLDivElement
Set ResultDIV = HTMLDoc.getElementById("resultsTooltip*")
让我说返回的 html 有一个不同的 id(数字会变化),具体取决于每个结果,因此每个 DIV 的 id 始终是:
id=resultsTooltipxxxxxxxContents
where xxxxxxx
总是不同的数字
任何帮助将不胜感激。
尝试这样的事情:
Dim ContainerDiv As HTMLDivElement, ResultDIV As HTMLDivElement
Set ContainerDiv = HTMLDoc.getElementById("rowToolTipContainer")
For Each ResultDIV In ContainerDiv.GetElementsByTagName("div")
If ResultDIV.ID Like "resultsTooltip*Contents" Then
'' What do you want to do here?
Exit For
End If
Next
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)