通过js来获取select的全部值,包括id,text,value
2017-01-17 09:16
567 查看
<html>
<head>
<title></title>
<script type=text/javascript>
function getselect(n){
var v = '';
var t = '';
for(var i = 0; i < n.options.length; i++){
if(i==0){
t = n.options[i].id;
v = n.options[i].value;
}else{
t += ','+n.options[i].id;
v += ','+n.options[i].value;
}
}
alert(v+'|'+t);
}
</script>
</head>
<body>
<table>
<form name="form1">
<tr>
<td>
<select name="n1" id="n1">
<option value='1' id="a">项目1</option>
<option value='2' id="b">项目2</option>
<option value='3' id="c">项目3</option>
<option value='4' id="d">项目4</option>
<option value='5' id="e">项目5</option>
</select>
</td>
</tr>
<tr>
<td><a onclick="getselect(document.form1.n1)" href="#">获取</a></td>
</tr>
</form>
</table>
<body>
</html>
相关文章推荐
- JS 获取select的value和text值
- js获取select的value或者text
- JS获取select-option-text_value的方法
- 用js分别获取select的value 和 text 文本
- JS获取页面所有input type=“text”的ID和value
- js 获取selectvalue text
- 关于JS获取select的值(value和text)
- js中创建html标签、加入select下默认的option的value和text、删除select元素节点下全部的OPTION节点
- js 获取select标签的value 和 text
- JS获取select-option-text_value
- JS获取select的value和text值的简单实例
- JS获取页面所有input type=“text”的ID和value
- JS 获取select的value和text值
- js 通过id获取value
- JS获取jQuery获取当前<input type="text" />的value--通过测试了
- JS获取select-option-text_value的方法
- jQuery获取Select选择的Text和 Value
- jQuery获取Select选择的Text和 Value(转)
- jQuery获取Select选择的Text和 Value(转)