动态的打字效果,代码不解!请教!!!
<script type=\\\"text/JavaScript\\\">
<!--
var txt = \\\"大家请看,这里就是效果\\\";
var chars = txt.length + 1; //应该是11+1=12=chars
var newstatus = \\\"\\\";
var i = 0;
function txtinstatus()
{
if (i < chars) //i小于12
{
setTimeout(\\\"nextletter()\\\", 200);
}
}
function nextletter()
{
if ((i+1)>=chars) // 不懂的地方,i+1>=12不是初始值只有0吗?
{
newstatus = txt.substring(0,i)
}
else //怎么会ELSE呢?
{
newstatus = txt.substring(0,i)+\\\"■\\\";
}
window.status = newstatus;
i++;
txtinstatus();
}
// -->
</script>
问题在我第一个循环就是0+1=1=i
1>=12??? 怎么会有循环呢?newstatus = txt.substring(0,i)