您现在的位置: 万盛学电脑网 >> 程序编程 >> 网页制作 >> Html5 >> 正文

html5 获取input内容

作者:佚名    责任编辑:admin    更新时间:2022-06-22

 <!doctype html> 

<html> 
<head> 
<meta charset=utf-8 /> 
<title>html5 获取input内容</title> 
</head> 
<body> 
  <input type="email" /> 
  <input type="tel" /> 
  <input type="range" /> 
  <input type="url" /> 
  <input type="number" /> 
  <input type="tel" /> 
  <input type="date" /> 
  <input type="datetime" /> 
  <ol id="debug"></ol>

<script>var d = document.getelementbyid('debug');
[].foreach.call(document.queryselectorall('input'), function (el) {
  d.innerhtml += '<li>' + el.type;
  d.innerhtml += el.getattribute('type')  + '</li>';
});
</script>  
</body> 
</html>