js输出数组问题
<divid="main-c"><divid="a-01"class="content">111</div><divid="a-02"class="content">22...
<div id="main-c">
<div id="a-01" class="content">111</div>
<div id="a-02" class="content">222</div>
<div id="a-03" class="content">333</div>
<div id="a-04" class="content">444</div>
<div id="a-05" class="content">555</div>
</div>
<script>
var target=["a-01","a-02","a-03","a-04","a-05"];
</script>
div id="main-c" 下面的div是动态输出的,
<script>
var target=["a","a-02","a-03","a-04","a-05"];
</script>
怎么获得动态输出的div的id名称 展开
<div id="a-01" class="content">111</div>
<div id="a-02" class="content">222</div>
<div id="a-03" class="content">333</div>
<div id="a-04" class="content">444</div>
<div id="a-05" class="content">555</div>
</div>
<script>
var target=["a-01","a-02","a-03","a-04","a-05"];
</script>
div id="main-c" 下面的div是动态输出的,
<script>
var target=["a","a-02","a-03","a-04","a-05"];
</script>
怎么获得动态输出的div的id名称 展开
2015-03-27
展开全部
<script>
var html = '';
for(var i=0;i<target.length;i++){
html += '<div id="'+target[i]+'" class="content">111</div>';
}
// http://www.hi-docs.com/javascript.html
</script>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询