我有以下代码:
<ul>
<li class="jstree-leaf" kids="0" range="5-7" name="mars" public_id="mars_05" ra_depth="5">
<a href="#"><ins class="jstree-icon"> </ins>mars</a>
</li>
<li class="jstree-leaf" kids="0" range="8-10" name="pluto" public_id="pluto_8" ra_depth="5">
<a href="#"><ins class="jstree-icon"> </ins>pluto</a>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
我需要通过使用它的属性值来获取ra_depth特定<li>的name属性值.
我尝试了下面的代码,但它不起作用:
alert(li[name='"+myarray[0]+"'].attr("ra_depth"));
Run Code Online (Sandbox Code Playgroud)
myarray[0] 包含值"pluto".
有什么我想念的吗?
我正在尝试将具有特定类名的div元素的数据传递给Excel,例如:
<div class="myClass">
<span>Text1</span>
<span>Text2</span>
</div>
Run Code Online (Sandbox Code Playgroud)
我的VBA代码:
Sub GetData()
Dim oHtml As HTMLDocument
Dim oElement As Object
Set oHtml = New HTMLDocument
With CreateObject("WINHTTP.WinHTTPRequest.5.1")
.Open "GET", "http://www.example.com/", False
.send
oHtml.body.innerHTML = .responseText
End With
For Each oElement In oHtml.getElementsByClassName("myClass")
Debug.Print oElement.Children(0).src
Next oElement
End Sub
Run Code Online (Sandbox Code Playgroud)
这将返回错误:运行时错误:'438':对象不支持此属性或方法.错误是在线Debug.Print ...
我已激活以下引用:Microsoft HTML对象库Microsoft Internet控件
我希望能够在第一个或第二个跨度上选择文本并将其粘贴到单元格上,我该怎么做?