var str1=obj.split(",");
for(var i=0;i<str1.length;i++)
{
alert(i+"a");
databande(500,500,i+"个div",i);
}function databande(width,hight,tetle,id)
{
var divstring="<div style=' border: 1px solid #BFE0F9; vertical-align: top; margin-top: 3px; height: "+hight+"px; float:right; width:"+width+"px;'>";
divstring+="<div style='background-image: url(fr-bg2.gif); height: 28px; border-bottom:1px solid #BFE0F9;' align='center'>";
divstring+="<div style='padding: 3px; width:"+width+"px; height:28px; float:left; text-align:left; font-weight:bold; color:#336FCC;'>";
divstring+=""+tetle+"</div>";
divstring+="</div>"+id+"</div>";
document.write(divstring);
return;
}循环只执行一次!!这是为什么?
for(var i=0;i<str1.length;i++)
{
alert(i+"a");
databande(500,500,i+"个div",i);
}function databande(width,hight,tetle,id)
{
var divstring="<div style=' border: 1px solid #BFE0F9; vertical-align: top; margin-top: 3px; height: "+hight+"px; float:right; width:"+width+"px;'>";
divstring+="<div style='background-image: url(fr-bg2.gif); height: 28px; border-bottom:1px solid #BFE0F9;' align='center'>";
divstring+="<div style='padding: 3px; width:"+width+"px; height:28px; float:left; text-align:left; font-weight:bold; color:#336FCC;'>";
divstring+=""+tetle+"</div>";
divstring+="</div>"+id+"</div>";
document.write(divstring);
return;
}循环只执行一次!!这是为什么?
解决方案 »
- 怎么动态创建一个Input元素
- 如何等待上传完毕后才提交表单?
- js代码
- 如何定时让内容一行一行输出来,而不是一下子就都出来
- 求助:在一个时间段中除去双休日的javascript代码
- Vml+DHtml:VML画板(FYWVml3.0)发布,欢迎在线使用\下载
- 〖新手上路〗页面里只有一个<input ……>,怎么取其值作为参数传递啊???
- 怎样才能更好的动态设置图片框的大小?
- 为什么大多数的style中第一句都是position:absolute;此句是什么意思?
- 绝对的难题,需要真正的高手
- function与Function,这两种写法,在javascript中,区别是什么?(一个大写,一个小写开头)
- 求解button的onclick问题
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script language="javascript">
var obj = "a,b,c,d";
var str1=obj.split(",");
for(var i=0;i<str1.length;i++)
{
alert(i+str1[i]);
databande(500,500,i+"个div",i);
}
function databande(width,hight,tetle,id)
{
var divstring="<div style=' border: 1px solid #BFE0F9; vertical-align: top; margin-top: 3px; height: "+hight+"px; float:right; width:"+width+"px;'>";
divstring+="<div style='background-image: url(fr-bg2.gif); height: 28px; border-bottom:1px solid #BFE0F9;' align='center'>";
divstring+="<div style='padding: 3px; width:"+width+"px; height:28px; float:left; text-align:left; font-weight:bold; color:#336FCC;'>";
divstring+=""+tetle+"</div>";
divstring+="</div>"+id+"</div>";
document.write(divstring);
return;
}
</script>
</HEAD>
<BODY>
</BODY>
</HTML>
str1.length
这个值你输出过了没 先确定这个值>1