如何用JS在文本中输入几个数字,然后在数组中随机出现几个数字并输出?
写个例子?随机数1-10
& lt!DOCTYPE?html & gt
& lthtml?lang="en " >
& lthead & gt
& ltmeta?charset="UTF-8 " >
& lttitle & gt文档& lt/title & gt;
& lt/head & gt;
& ltbody & gt
& lt输入?type="text "?id = ' tx ' & gt
& lt按钮?onclick = " rd()" & gt;计算
& ltbr & gt
& lttextarea?id='con '?style="width:?200px身高:?500像素" >& lt/textarea & gt;
& lt/body & gt;
& lt剧本?type = " text/JavaScript " & gt;
功能?rd?()?{
nb=document.getElementById('tx ')。价值;
s =“”;
for(I = 0;我& ltnb;i++){
s = s+math . ceil(math . random()* 10)+' \ n ';
}
document.getElementById('con ')。值= s;
}
& lt/script & gt;
& lt/html & gt;