select 动态填充option选项及获取选择的值或者所有值
来源:互联网 发布:网络著作权侵权行为 编辑:程序博客网 时间:2024/06/05 09:32
一:页面HTML代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ECharts</title>
</head>
<body onload="add();">
<select id="sele" style="left: 43px; width: 184px; top: 103px" onchange="_change()">
<option selected="selected">请选择</option>
</select>
<script type="text/javascript">
function add() {//动态设置option选项
for (var i = 0; i < 5; i++) {
var newOption = document.createElement("option");
newOption.value = i;
newOption.text = i;
document.getElementById("sele").options.add(newOption);
}
}
</script>
</body>
<script type="text/javascript">
function _change() {
var sele = document.getElementById("sele").value;//获取选择的选项卡
var seles = document.getElementById("sele").options;//获取所有的选线卡-数组
console.log(sele);
console.log(seles.length);
}
</script>
</html>
二:效果
- select 动态填充option选项及获取选择的值或者所有值
- jquery获取select选项option的值
- 动态填充checkbox的选项,及获取值
- 【JqGrid】jqGrid动态填充select下拉框的选项值
- jquery获取一个select里面的所有option的值
- jQuery获取select中所有option值
- jQuery获取select中所有option值
- JS动态改变select选择变更option的index值
- JS动态改变select选择变更option的index值
- JS动态改变select选择变更option的index值
- JS动态改变select选择变更option的index值
- 下拉列表select动态添加option和获取选中的option的值和value
- 得到select所有option里的值
- JS动态改变select选择变更option的index值(js操作select)
- 选择select框下option的值
- 获取页面中name相同的input或者select标签的option值
- 关于Select option默认选中及查询后选项值保留的问题
- 关于Select option默认选中及查询后选项值保留的问题
- VPP API注册回调函数--待完成
- 三级模式两级映像/数据库系统结构
- zookeeper 3.4.6启动抛出 Invalid arguments, exiting abnormally java.lang.NumberFormatException 异常
- Git使用流程
- 我的
- select 动态填充option选项及获取选择的值或者所有值
- 03-VTK基础概念(1)
- java.net.SocketException: No buffer space available (maximum connections reached?): JVM_Bind
- Could not read JSON: Can not deserialize instance of java.lang.String[] out of VALUE_STRING token
- ASP.NET MVC 随想录——开始使用ASP.NET Identity,初级篇
- 求两个整数之和
- android.content.ActivityNotFoundException: No Activity found to handle Intent
- Coursera吴恩达《神经网络与深度学习》课程笔记(3)-- 神经网络基础之Python与向量化
- python3.5将list类型转换为矩阵类型