input checkbox 多选 验证
2024-09-30 03:33:49
# input checkbox 多选 验证
```
<ul class="orderMsg_radio">
<!--单选--> <input value="1" type="checkbox" value=1 id="1" name="cart-pro" class="regular-radio">
<label for="1" class="sel-this"><em style="border-radius: 0"></em>电子手表</label> <input value="2" type="checkbox" value=2 id="2" name="cart-pro" class="regular-radio">
<label for="2" class="sel-this"><em style="border-radius: 0"></em>耳机</label> <input value="3" type="checkbox" value=3 id="3" name="cart-pro" class="regular-radio">
<label for="3" class="sel-this"><em style="border-radius: 0"></em>数据线</label> <input value="4" type="checkbox" value=4 id="4" name="cart-pro" class="regular-radio">
<label for="4" class="sel-this"><em style="border-radius: 0"></em>充电器</label> </ul>
var check_val ;
function fun(){
obj = document.getElementsByName("cart-pro");
check_val=[]
for(k in obj){
if(obj[k].checked)
check_val.push(obj[k].value);
}
return check_val;
}
console.log(check_val); ```
输出你选中的 checkbox的值得数组
最新文章
- 2000条你应知的WPF小姿势 基础篇<;63-68 Triggers和WPF类逻辑结构>;
- Android 自定义View及其在布局文件中的使用示例
- ABAP游标的使用
- PHP simplexml_load_string 过滤<;![CDATA[XXXX]]>;
- lightning mdb 源代码分析(2)
- RMQ (Range Minimal Query) 问题 ,稀疏表 ST
- angularJs中的隐藏和显示
- 1128. Partition into Groups(图着色bfs)
- UIButton 按钮文字左对齐
- Asp.net实现在线人数统计功能代码实例
- (转)c#对象内存模型
- 移动开发中的Scheme跳转说明——Allowing OtherApps to Start Your Activity
- Linux中添加管理员权限问题:xxx is not in the sudoers file. This incident will be reported.
- vue过渡和animate.css结合使用
- 跨server传输数据注意事项
- 如何排查CPU飙升的Java问题
- 二、Redis安装
- .Net Core中的Api版本控制
- SQL server 2008(Linux安装)
- Redis和memcached缓存技术