日期:2014-05-16 浏览次数:20437 次
<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>HTML DOM创建元素本文</title> </head> <body> <form id="form1" runat="server"> <div> <h2>下拉框</h2> <div id="testDiv"></div> </div> <script type="text/javascript"> var select=document .createElement("select"); select.options[0] = new Option("加载项1", "value1"); select.options[1] = new Option("加载项2", "value2"); select.options[2] = new Option("加载项3", "value3"); select.options[3] = new Option("加载项4", "value4"); select.size = "4"; document.getElementById('testDiv').appendChild(select); </script> </form> </body> </html>
<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>HTML DOM创建元素本文</title> <script type="text/javascript"> var select=document .createElement("select"); select.options[0] = new Option("加载项1", "value1"); select.options[1] = new Option("加载项2", "value2"); select.options[2] = new Option("加载项3", "value3"); select.options[3] = new Option("加载项4", "value4"); select.size = "4"; document.getElementById('testDiv').appendChild(select); </script> </head> <body> <form id="form1" runat="server"> <div> <h2>下拉框</h2> <div id="testDiv"></div> </div> </form> </body> </html>
$(document).ready(function(){ //js代码 });
------解决方案--------------------
顺序问题!!!!!!!!!!!!!!
------解决方案--------------------