我有一些看起来像这样的 html,我需要 address1 范围、城市范围和州范围类的 innerHTML 内容,分别用于不同的 std-address 类。
<div id="result-list">
<div class="data">
<p class="std-address">
<span class="address1 range">some html content</span>
<span class="city range">some html content</span>
<span class="state range">some html content</span>
</p>
<p class="std-address">
<span class="address1 range">some html content</span>
<span class="city range">some html content</span>
<span class="state range">some html content</span>
</p>
<p class="std-address">
<span class="address1 range">some html content</span>
<span class="city range">some html content</span>
<span class="state range">some html content</span>
</p>
</div>
</div>
我编写了下面提到的代码,它工作正常,直到我在 IE 8 及更低版本上测试它
var addArrayX = document.getElementById("result-list").getElementsByClassName("std-address");
for (i=0;i<addArrayX.length;i++){
var address = addArrayX[i];
stLine1 = trim(((address.getElementsByClassName("address1 range"))[0]).innerHTML);
city = trim(((address.getElementsByClassName("city range"))[0]).innerHTML);
state = trim(((address.getElementsByClassName("state range"))[0]).innerHTML);
}
请帮助我使此代码与 IE 兼容(最好使用 js 或通过 jQuery)