如何获取div里的内容?

2156单</span><br/>起送¥0<span id="free5">免费配送</span><span id="time5">43分钟</span></p><input id="bt5" type="button" value="加入购物车" onclick="putin(this)"></div>
<div id="hanber"><img src="img/1cde.jpg" width="300px" height="200px"><p id="f1"><span name="q1">A米汉堡<span><span id="price1">16元/份</span><br/><span id="sp1">月销8148单</span><br/>起送¥10<span id="free1">免费配送</span><span id="time1">45分钟</span></p><input id="bt1" type="button" value="加入购物车" onclick="putin(this)"></div>

<!DOCTYPE html><html><head>
<title></title>
<script type="text/javascript">

function getElements(){
var x=document.getElementsByName("div"); for(var i=0;i<x.length; i++){
alert(x[i].innerHTML);
}
} </script></head><body>
<div id="1">1231</div>
<div id="2">qweq</div>
<div id="3">qw12</div>
<div id="4">as12</div>
<div id="5">zx12</div></body></html>12345678910111213141516171819202122

输出内容
1231
qweq
qw12
as12
zx12
温馨提示:答案为网友推荐,仅供参考
相似回答
大家正在搜