jq 如何获取多选框选中的值
jquery如何获取多选框选中的值,有两种方法
1、通过id获取是否选中(单个)
1)引入jquery文件
2)Html设计如下
<div>
<span>运动类:</span>
<div id="div1" style="position:relative;left:80px;margin-top:-16px;">
<input type="checkbox" size="12" name="Sports" id="Pingpong" value="1"/>乒乓球
<input type="checkbox" size="12" name="Sports" id="Badminton" value="2"/>羽毛球
<input type="checkbox" size="12" name="Sports" id="Basketball" value="3"/>篮球
<input type="checkbox" size="12" name="Sports" id="Billiards" value="4"/>台球
</div>
<div id="div2" style="position:relative;left:80px;margin-top:10px;">
<input type="button" value="提交1" onClick="SaveCheck1()"/>
<input type="button" value="提交2" onClick="SaveCheck2()"/>
</div>
</div>
3)js中获取方法(单个)
var SaveCheck1 = function(){
//通过id获取多选框是否选中
var pinpong = $('#Pingpong').is(":checked");
var badminton = $('#Badminton').is(":checked");
var basketball = $('#Basketball').is(":checked");
var billiards = $('#Billiards').is(":checked");
//在控制台输出选中值
console.log("乒乓球:"+pinpong);
console.log("羽毛球:"+badminton);
console.log("篮球:"+basketball);
console.log("台球:"+billiards);
}
4)运行的结果
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAooAAACVCAIAAABQCUy8AAAa7klEQVR4nO3dW08b16IH8Pko/gQ8VztPUZtbH0q2t6o+RO3OPpKbNg2kfSEhDumRKMdUPVVLTIBYpE3JTlyjqDkgCNm5HbVSwKJAnV5UgXcCUZo4bTHdphG7EZfZD8tes2ZmzXjNeMazBv9/QpGZm9eyw/y9Lp5RVAAAqEilUiUACShB/y0AAEgE8QySQDwDAGgQzyAJxDMAgAbxDJJAPAMAaBDPIAnEMwCAJqh4/vjjj2O2Pv7446oHmZycrENRoT4QzwAAmqDiORaL1bhBCfG8vSCeAQA0VeM5nU6/9dZbVm3cN9988+LFiy7OxYhnMEA8AwBoqsbzW2+9Zb/Bm2++6eJcjHgGA8QzAICmajx7kqM+HdZFPN++fTta0dLSUiqVcrlcV1eX0+NIor29vampqamp6cCBA34cv6mp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4BADSIZ5AE4hkAQIPObZAE4hkAQIOpYSAJxDMAgAZfrAJJIJ4BADS4LAlIAvEMAKBBPIMkEM8AABrEM0jiP0sae/ba8BrGAAAAAElFTkSuQmCC" alt="" width="512" height="149" />
2、通过name获取是否选中(一组)
1)引入jquery文件(如上)
2)Html设计(如上)
3)js获取选中值(一组)
var SaveCheck2 = function(){
var arry = new Array();
//循环所有选中的值
$('input[name="Sports"]:checked').each(function(index, element) {
//追加到数组中
arry.push($(this).val());
});
//将数组元素连接起来转化为字符串
var arrystr = arry.join(',');
//输出到控制台
console.log("选中值:"+ arrystr);
}
4)运行的结果
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAo0AAABtCAIAAABLFMyxAAAWy0lEQVR4nO2d228T177H50/hL8hzJZ4QBZI+NMhS1Qd2K3QkEyLIldycEDgi5DiI00IIBWK2tFGyiUkUlRPLNGwE6e5D4jTExQGqyqS7TgqJaUnSmrLZpImzzsOyl+fuNVfbyfejeZjMrDWzfjPx+sy6eCz8DgAAAIBiRSh0AQAAAACgifDl6JdYsGDBggULluJcBAIAAICPQCCQAsBd4GkAAOAFngbuA08DAAAv8DRwH3gaAAB4gaeB+8DTAADACzwN3AeeBgAAXgrl6YsXL3p1uXjxYt6DTE1NuVBUYDvwNAAA8FIoT3u9XosJUvB0yQJPAwAAL3k9HQwGjx07ptXqra6uvnnzpomaGp7eycDTAADAS15PHzt2TD9BdXW1iZoant7JwNMAAMBLXk/bIlSHDmvC0xMTE54sNTU1qVQqFot1d3cbPU6R4PP5ysrKysrKDh065MTxy8rKnDgsPA0AALy47Gnl9DGt+WLOeVoWsgueHh0dHR0dtf2whw4dYoMO0Wj03r17tp/CCU8HAgF4GgAAeLHuaUOoDnKbPu9O9vTNmzfNzQwwhBOe7u7u1vJ0MlhZGUza8o8d8Qvqh5LuSAYrBX/EkRIAAIAtGPV0T09Pf3///fv3E4mEiTpaad+i8nR3dzftEqdapbsCgYDH4+nu7l5YWBDvpbBe9Fgslsoquaam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/zDC3rezrvMLYJ5ufnd+/eDUkXFnh621Jw3RbK05St5eWN6mpbDgUAA7/DAdwHnt62FFy3hfU0AE4ATwP3gacBAICXQCCwBoC7wNMAAMAL2tPAfeBpAADgBZ4G7gNPAwAAL/A0cB94GgAAeIGngfvA0wAAwAs8DdwHngYAAF7gaeA+8DQAAPCS19N///o/Py5vulMYsEOApwEAgBd9T//xny3P//xR8d+pJwtQNbANeBoAAHjJ255++Vv60P++3ncyNR3fcKdIYNsDTwMAAC8849O/vdn6r0t/7Gn/fWJu3YUigW0PPA0AALzA08B94GkAAOAF/d7AfeBpAADgBfPIgPvA0wAAwAu+lwXcB54GAABe8J4T4D7wNAAA8AJPA/eBpwEAgBd4GrgPPA0AALzA08B94GkAAOAFngbuA08DAAAv8DRwH3gaAAB4gaeB+8DTAADACzwN3AeeBgAAXuBp4D7wNAAA8AJPA/eBpwEAgBd4GrgPPA0AALzA08B94GkAAOAFngbuA08DAAAv8DRwH3gaAAB4gaeB+8DTAADACzwN3AeeBgAAXuBp4D7/DybCVcwoOvGkAAAAAElFTkSuQmCC" alt="" width="547" height="109" />
3、整个demo源码
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>如何获取多选框选中的值</title>
</head>
<script src="jquery.min.js"></script> <script>
var SaveCheck1 = function(){
//通过id获取多选框是否选中
var pinpong = $('#Pingpong').is(":checked");
var badminton = $('#Badminton').is(":checked");
var basketball = $('#Basketball').is(":checked");
var billiards = $('#Billiards').is(":checked");
//在控制台输出选中值
console.log("乒乓球:"+pinpong);
console.log("羽毛球:"+badminton);
console.log("篮球:"+basketball);
console.log("台球:"+billiards);
} var SaveCheck2 = function(){
var arry = new Array();
//循环所有选中的值
$('input[name="Sports"]:checked').each(function(index, element) {
//追加到数组中
arry.push($(this).val());
});
//将数组元素连接起来转化为字符串
var arrystr = arry.join(',');
//输出到控制台
console.log("选中值:"+ arrystr);
} </script>
<body>
<div>
<span>运动类:</span>
<div id="div1" style="position:relative;left:80px;margin-top:-16px;">
<input type="checkbox" size="12" name="Sports" id="Pingpong" value="1"/>乒乓球
<input type="checkbox" size="12" name="Sports" id="Badminton" value="2"/>羽毛球
<input type="checkbox" size="12" name="Sports" id="Basketball" value="3"/>篮球
<input type="checkbox" size="12" name="Sports" id="Billiards" value="4"/>台球
</div>
<div id="div2" style="position:relative;left:80px;margin-top:10px;">
<input type="button" value="提交1" onClick="SaveCheck1()"/>
<input type="button" value="提交2" onClick="SaveCheck2()"/>
</div>
</div>
</body>
</html>
jq 如何获取多选框选中的值的更多相关文章
- jquery获取select多选框选中的值
select下拉框选中的值,用jquery大家应该都会获取, $("#selectBox option:selected").val(); 如果select是多选的,也这么获取的话 ...
- jsp获取多选框组件的值
jsp获取多选框组件的值 1.首先写一个带有多选框的前台页 1 <%@ page language="java" contentType="text/html; c ...
- JS获取页面复选框选中的值
function jqchk(){ //jquery获取复选框值 var chk_value =[]; $('input[class="sel"]:checked').each(f ...
- jquery获取复选框checkbox的值
jQuery API : each(callback) :以每一个匹配的元素作为上下文来执行一个函数. :checked :匹配所有选中的被选中元素(复选框.单选框等,不包括select中的optio ...
- Winforn中导入Excel并显示然后获取多选框选中的内容
场景 使用NPOI导入Excel并赋值给DataTable,然后显示在DataGrdView上,并且添加多选框,然后获取选中行的内容. Winform中使用NPOI实现Excel导入并赋值给DataT ...
- layui 获取radio单选框选中的值
Layui 获取 radio的值,layui判断radio选中的单选值 layui form 表单获取radio选中的值 首先准备两个radio <input type="radio& ...
- jQuery获取复选框选中的每一个值
$('input[name="serviceMode"]:checked').each(function(){ this.attr('value') });
- javascript如何获取复选框中的值?
思路:获取checkbox对象→循环checkbox数组,根据checked属性判断是否选中→使用value属性获取选中项的值.实例演示如下: 1.HTML结构 <form> <in ...
- Js获取复选框checkbox的值
var emps= $("input[name='emp']:checked"); var employee= ""; emps.each(function() ...
随机推荐
- springboot学习之授权Spring Security
SpringSecurity核心功能:认证.授权.攻击防护(防止伪造身份) 涉及的依赖如下: <dependency> <groupId>org.springframework ...
- 网络安装OS(配置文件)
●无人值守安装KS文件(redhat用,删除下面中文). #LinuxIParm Config File #Generated by LinuxIParm Configurator #Boot Mod ...
- echart 注意事项-初始化和销毁
net5x 博客园 首页 新随笔 联系 管理 订阅 随笔- 21 文章- 186 评论- 4 ECharts图表初级入门(三):ECharts对象的数据实例化方法汇总以及注意事项 [摘要]: ...
- nodejs模拟http发送请求
首先需要安装模块request,然后代码如下: //模拟发送http请求 var request = require("request"); //get请求 request('ht ...
- (转)SPI时钟极性、时钟相位
SPI协议是一个 4 线.全双工的串口协议.根据串口时钟SCLK的相位SCPH和极性SCPOL的不同,有 4 种组合. CPOL CPHA MODE0 0 0 MODE1 0 1 MODE2 1 0 ...
- Program Option Modifiers
Some option are 'boolean' and control behavior that can be turned on or off. --column-names option d ...
- English Voice of <<if were a boy >>
<if i were a boy>中英文歌词: If I were a boy 如果我是个男孩 Even just for a day 就算只是一天 I' roll out of bed ...
- hdu-3366 Passage 概率DP 读懂就能AC hhh
http://acm.split.hdu.edu.cn/showproblem.php?pid=3366 读题的时候没发现这个P Q 1-P-Q是全集的划分,以为是独立事件,写错了转移方程233 先贪 ...
- 02 爬虫数据解析之re,xpath,beautifulsoup
一.正则匹配 简单用法演示: 字符: print(re.findall(".","abccc31223dn哈哈")) ### . 匹配除了换行符以外的任意字符, ...
- Python特点
用一种方法,最好只用一种方法来做一件事 1.面向对象(解决一个问题,先考虑由“谁”来做,怎么做是“谁”的职责) 函数.模块.数字.字符串都是对象 在Python中一切皆对象 完全支持继承.重载.多重继 ...