网上讲JS动态添加option和删除option的文章很多,在此推荐一篇: http://www.jb51.net/article/35205.htm 我使用的是如下方法: function removeAll(){ var obj=document.getElementById('mySelect'); obj.options.length=0; } 由于使用jQuery习惯了,获取select对象时使用的JQuery的Id选择器,恰恰因为这个,发现一个问题: 显示TypeError,jQue…
js 操作select和option 1.动态创建select function createSelect(){ var mySelect = document.createElement_x("select");          mySelect.id = "mySelect";           document.body.appendChild(mySelect);      } 2.添加选项option function addOption(){ //根…
1.js代码 $("#year").append("<option value="+value的值+">"+内容+"</option>"); 2.jsp <select id="year"></select>…
1.动态创建select function createSelect(){ var mySelect = document.createElement_x("select"); mySelect.id = "mySelect"; document.body.appendChild(mySelect); } 2.添加选项option function addOption(){ //根据id查找对象, var obj=document.getElementByIdx_x…
<select id="shi"> function loadInfo(){ var shengId=document.getElementById("sheng").value; shi.options.length=0; // 删除所有市下拉框的选项 var xmlHttp; if(window.XMLHttpRequest){ xmlHttp=new XMLHttpRequest(); }else{ xmlHttp=new ActiveXObjec…
1.获取选中select的value和text,html代码如下: <select id="mySelect"> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select> $(&qu…
1.获取选中select的value和text,html <select id="mySelect"> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select> 通过以下script…
//document.writeln(document.getElementById("sel").options.length); //document.writeln(document.getElementById("sel")["options"].length); //document.writeln(document.getElementById("sel").children.length);…
js实现不同select标签option值的验证 功能描述: 选择中文时,匹配中文的正则表达式,选择英文选项是匹配英文的表达式,并且有对应的提示信息. html代码片段: <select id="word_type" name="S1"> <option value="0">中文</option> <option value="1">英文</option> </…
<select id="ddlResourceType" onchange="getvalue(this)"> </select> 动态删除select中的所有options: document.getElementById("ddlResourceType").options.length=0; 动态删除select中的某一项option: document.getElementById("ddlResourc…