zoukankan
html css js c++ java
JQuery:单选框,复选框取值
<
div style
=
"
100%; border:solid 1px #0000ff; line-height:25px
"
>
<
input type
=
"
radio
"
name
=
"
items
"
id
=
"
item1
"
value
=
"
1
"
checked
=
"
checked
"
/
>1
<
input type
=
"
radio
"
name
=
"
items
"
id
=
"
item2
"
value
=
"
2
"/
>2
<
input type
=
"
radio
"
name
=
"
items
"
id
=
"
item3
"
value
=
"
3
"/
>3
<
input type
=
"
radio
"
name
=
"
items
"
id
=
"
item4
"
value
=
"
4
"/
>4
<
input type
=
"
radio
"
name
=
"
items
"
id
=
"
item5
"
value
=
"
5
"/
>5
<
br
/
>
<
input id
=
"
bt_radio
"
type
=
"
button
"
value
=
"
单选框测试
"
>
<
script type
=
"
text/javascript
"
>
$(document).ready(
function
()
{
$(
"
#bt_radio
"
).click(
function
()
{
alert($(
"
input[@name=items][@checked]
"
).val());
}
)
}
)
<
/
script>
<
/
div>
<
br
/
>
<
div style
=
"
100%; border:solid 1px #0000ff; line-height:25px
"
>
<
input type
=
"
checkbox
"
name
=
"
cbType1
"
id
=
"
cbType1
"
value
=
"
1
"
checked
/
>1
<
input type
=
"
checkbox
"
name
=
"
cbType1
"
id
=
"
cbType2
"
value
=
"
2
"
/
>2
<
input type
=
"
checkbox
"
name
=
"
cbType1
"
id
=
"
cbType3
"
value
=
"
3
"
checked
/
>3
<
input type
=
"
checkbox
"
name
=
"
cbType1
"
id
=
"
cbType4
"
value
=
"
4
"
checked
/
>4
<
br
/
>
<
input id
=
"
bt_checkbox
"
type
=
"
button
"
value
=
"
多选框测试
"
>
<
script type
=
"
text/javascript
"
>
$(document).ready(
function
()
{
$(
"
#bt_checkbox
"
).click(
function
()
{
var
aa
=
""
;
$(
"
input[@name=cbType1][@checked]
"
).each(
function
()
{
aa
+=
$(
this
).val()
+
"
,
"
;
}
)
alert(aa);
}
)
}
)
<
/
script>
<
/
div>
<
br
/
>
<
div style
=
"
100%; border:solid 1px #0000ff; line-height:25px
"
>
<
input type
=
"
checkbox
"
name
=
"
cbType2
"
id
=
"
cbType21
"
value
=
"
1
"
checked
/
>1
<
input type
=
"
checkbox
"
name
=
"
cbType2
"
id
=
"
cbType22
"
value
=
"
2
"
/
>2
<
input type
=
"
checkbox
"
name
=
"
cbType2
"
id
=
"
cbType23
"
value
=
"
3
"
checked
/
>3
<
input type
=
"
checkbox
"
name
=
"
cbType2
"
id
=
"
cbType24
"
value
=
"
4
"
checked
/
>4
<
br
/
>
<
input id
=
"
bt_checkbox2
"
type
=
"
button
"
value
=
"
多选框测试2
"
>
<
script type
=
"
text/javascript
"
>
$(document).ready(
function
()
{
$(
"
#bt_checkbox2
"
).click(
function
()
{
var
aa
=
""
;
$(
"
input[@name=cbType2]
"
).each(
function
()
{
if
(
this
.checked)
{
aa
+=
this
.value
+
"
,
"
;
}
}
)
alert(aa);
}
)
}
)
<
/
script>
<
/
div>
查看全文
相关阅读:
setTimeOut 和 setInterval对比
vue官方源码剖析
Taro 总结
地图相交
vscode 配置文件
redis持久化的几种方式
推荐.Net、C# 逆向反编译四大工具利器
【转】Java 通过JDBC连接Mysql数据库的方法和实例【图文说明】
【摘】Oracle 11g EM安全证书问题无法访问的解决办法
MySql 从SQL文件导入
原文地址:https://www.cnblogs.com/liydotnet/p/1134240.html
最新文章
JAVA静态代码块的作用
数据段、代码段、堆栈段、BSS段的区别
openssh 安装
bootstrap分割式下拉菜单显示不全
jquery遍历json对象数组,报错
Oracle PIVOT 行转列方法
VS 日历控件取值时的格式问题
VS 控件常见的属性设置问题
C# 获取DataTable某列的最大值
C# TryParse()用法
热门文章
C# Datatable.Select()用法简介
C# string.Format()用法
C# datatable 去重
数据表查询时的去重
C# 调用.exe文件
http总结
addEventListener
微信公众号清除缓存
浏览器背后的运行机制
js中new 到底做了什么?
Copyright © 2011-2022 走看看