展开全部
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
</head>
<body>
<input type="text" id="txt1" >
<input type="button" value="提交" id="btn1">
<script>
var txt1=document.getElementById("txt1");
var btn1=document.getElementById("btn1");
btn1.onclick=function(){
var nums=txt1.value.split(" ");//用空格分割字符串
for(var i=0;i<nums.length;i++){
alert(nums[i]);
}
}
</script>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询