实现效果:
代码:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<form action="">
请输入邮箱:<input type="text" name="search" placeholder="请输入邮箱"><br/>
请输入手机:<input type="text" name="search" placeholder="请输入手机"><br/>
<input type="button" value="提交" onclick="check();" style="background: #e840f3">
</form>
</body>
</html>
<script>
function check(){
var els =document.getElementsByName("search");
for (var i = 0, j = els.length; i < j; i++){
console.log(els[i].value);
}
}
</script>
OK