日期:2014-05-16 浏览次数:20358 次
<div> <span>1</span> <span>2</span> <span>3</span> <span>4</span> </div>
<div id="div1"> <span>1</span> <span>2</span> <span>3</span> <span>4</span> </div> <script type="text/javascript" > var ospans=document.getElementById("div1").getElementsByTagName("span"); var spanarr = new Array; alert(ospans.length); for (var i = 0; i < ospans.length; i++) { spanarr.push(ospans[i].innerHTML); } alert(spanarr.join(",")); </script>