<html><head> <meta charset="UTF-8"></head><body> <div class="btn">x1</div> <div class="btn">x2</div> <div class="btn">x3</div> <div class="btn">x4</div></body> <script type="text/javascript" > var x=document.getElementsByClassName("btn").length; document.write(x); </script></html>输出结果x1x2x3x44为何结果不是4 ?
6 回答
侃侃尔雅
TA贡献1801条经验 获得超16个赞
<div class="btn">x1</div>
<div class="btn">x2</div>
<div class="btn">x3</div>
<div class="btn">x4</div>
对应
x1
x2
x3
x4
添加回答
举报
0/150
提交
取消