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

前端之家收集整理的这篇文章主要介绍了jquery获取复选框checkbox的值实现方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

jQuery API :

函数。

包括select中的option)

js:

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

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()">

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

原文链接:https://www.f2er.com/jquery/48327.html

猜你在找的jQuery相关文章