jquery获取复选框checkbox的值实现方法

jQuery API :

一个匹配的元素作为上下文来执行一个函数

包括select中的option)

js:

rush:js;"> //js获取复选框值 var obj = document.getElementsByName("interest");//选择所有name="interest"的对象,返回数组 var s='';//如果这样定义var s;变量s中会认被赋个null值 for(var i=0;i添加到变量s中 }

jquery:

rush:js;"> //jquery获取复选框值 var chk_value =[];//定义一个数组 $('input[name="interest"]:checked').each(function(){//遍历每一个名字为interest的复选框,其中选中的执行函数 chk_value.push($(this).val());//将选中的值添加到数组chk_value中 });

其中jsp页面代码

<div class="jb51code">
<pre class="brush:xhtml;">
<%@ page language="java" contentType="text/html" import="java.util.*" pageEncoding="GBK"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
// basePath = http :// 127.0.0.1 : 8080 /DWR_checkbox /
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

DWR获取浏览器页面信息 <Meta http-equiv="pragma" content="no-cache"> <Meta http-equiv="cache-control" content="no-cache"> <Meta http-equiv="expires" content="0"> <Meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <Meta http-equiv="description" content="This is my page"> 用户名:获取信息" onclick="show()"/>测试权限
测试权限
dwr.util.setValue:
这是一个div标签
修改此行值 调用测试" onclick="invoke1()"> 删除所有行" onclick="invoke3()"> 修改行值" onclick="invoke4()">
irst.jsp" onclick="go_to()">
irst_jsp" style="width: 100%; height: auto; display:none">
VC VB VFoxpro VJava BC COobol Java Delphi 获取复选框值" onclick="getInfo()">
BoxInfo" style="width: 100%; height: auto; display:block">

以上这篇jquery获取复选框checkBox的值实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持编程之家。

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...