日期:2014-05-18  浏览次数:20644 次

javascript算法求解,请各位大虾帮忙!
有一个字符串String   str= "me ",有一个变量i=1,i <10(不重要)我想实现通过i的累加,i++实现字符串的这种变化:
str= "me1 ", "me3 "...用javascript可以实现吗?怎么做呢?最好有代码参考,多些了.

------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<html>
<head>
<title> New Document </title>
<meta name= "Generator " content= "EditPlus ">
<meta name= "Author " content= " ">
<meta name= "Keywords " content= " ">
<meta name= "Description " content= " ">
<script>
function theClick()
{
var value=document.getElementById( "val ").value;
var newValue= " ";
for(i=0;i <3;i++)
{
newValue=newValue+value+i;
}
document.getElementById( "newVal ").value=newValue;
}
</script>
</head>

<body>
<input type= "text " id= "val ">
<input type= "text " id= "newVal ">
<input type= "button " value= "clickme " onclick= "theClick() ">
</body>
</html>

------解决方案--------------------
javascript支持字符串和整型数相加,转化为字符串的