<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<input type="button" value="点击拼接" id="btn"></br>
<input type="text" value=""></br>
<input type="text" value=""></br>
<input type="text" value=""></br>
<input type="text" value=""></br>
<input type="text" value=""></br>
<input type="text" value=""></br>
<input type="text" value=""></br>
<input type="text" value=""></br>
<script>
document.getElementById("btn").onclick=function(){
var arr=[];
var inputs=document.getElementsByTagName("input");
for(var i=0;i<inputs.length;i++){
if(inputs[i].type!="button"){
//将文本框里的内容推入arr里面
arr.push(inputs[i].value);
}
}
//用|把每个推入的元素隔离起来
console.log(arr.join("|"));
};
</script>
</body>
</html>