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>
查看全文
相关阅读:
css 修改滚动条
target和currentTarget的区别
css 绘制对话框三角符号
sass/less/stylus css编译
angular 国际化
angularjs中展示富文本编辑器文本,向DOM中插入元素
炫酷动画效果,小球洒落,树木开花,深林效果
angular插件合集
css3 倒影
Promise简介
原文地址:https://www.cnblogs.com/liydotnet/p/1134240.html
最新文章
《python网络数据采集》读后感 第七章:数据清洗
《python网络数据采集》读后感 第六章:读取文档
leetcode 21. 合并两个有序链表
leetcode 20.有效的括号
《python网络数据采集》读后感 第五章:存储数据
《python网络数据采集》读后感 第四章:API
HTTP从网络服务获取信息
《python网络数据采集》读后感 第三章:开始采集2
leetcode 13.最长公共前缀
window窗口的各种宽高
热门文章
viewport详解
Chrome性能分析工具Coverage使用方法
Chrome性能分析工具lightHouse用法指南
serve-index用法、实现原理(源码解读)
像素详解
CSS各种度量单位----px、em、%、rem、vh/vw、vmin/vmax
响应式布局【5】--- 实战开发中遇到问题汇总
响应式布局【4】--- 业界使用情况分析
响应式布局【3】 --- bootstrap
angular ng-if scope权限问题
Copyright © 2011-2022 走看看