<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input type="button" value="拼接字符串" id="btn" /><br/>
<input type="text" /><br/>
<input type="text" /><br/>
<input type="text" /><br/>
<input type="text" /><br/>
<input type="text" /><br/>
<input type="text" /><br/>
<script>
document.getElementById("btn").onclick = function () {
var inputs = document.getElementsByTagName("input");
var str = [];
for (var i = 0; i < inputs.length; i++) {
if(inputs[i].type != "button"){
str.push(inputs[i].value);
}
}
console.log(str.join("|"));
};
</script>
</body>
</html>
网友评论