# 文本输入框下拉选择动态数据加载
~~~
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="text/javascript">
window.onload=load_pagedata;
function load_pagedata() {
var datas=["桔子","香蕉","苹果"];
var listsObj= document.getElementById("foodlists");
for(var i in datas)
{
var opObj=document.createElement("option");
opObj.setAttribute("value",datas[i]);
var nodeText =document.createTextNode(datas[i]);
opObj.appendChild(nodeText);
listsObj.appendChild(opObj);
}
}
</script>
</head>
<body>
<input list="foodlists">
<datalist id="foodlists">
</datalist>
</body>
</html>
~~~