惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
月光博客
月光博客
The Last Watchdog
The Last Watchdog
T
Tenable Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
Simon Willison's Weblog
Simon Willison's Weblog
V
Vulnerabilities – Threatpost
F
Fortinet All Blogs
Microsoft Security Blog
Microsoft Security Blog
A
Arctic Wolf
云风的 BLOG
云风的 BLOG
Know Your Adversary
Know Your Adversary
P
Palo Alto Networks Blog
GbyAI
GbyAI
阮一峰的网络日志
阮一峰的网络日志
The GitHub Blog
The GitHub Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
U
Unit 42
MyScale Blog
MyScale Blog
B
Blog
Spread Privacy
Spread Privacy
S
Schneier on Security
Project Zero
Project Zero
L
LINUX DO - 热门话题
M
MIT News - Artificial intelligence
F
Full Disclosure
WordPress大学
WordPress大学
Apple Machine Learning Research
Apple Machine Learning Research
Cyberwarzone
Cyberwarzone
AWS News Blog
AWS News Blog
aimingoo的专栏
aimingoo的专栏
博客园 - 三生石上(FineUI控件)
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
Security Latest
Security Latest
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Tailwind CSS Blog
K
Kaspersky official blog
Recent Announcements
Recent Announcements
NISL@THU
NISL@THU
Cisco Talos Blog
Cisco Talos Blog
S
Securelist
P
Privacy & Cybersecurity Law Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
The Exploit Database - CXSecurity.com
V
Visual Studio Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Webroot Blog
Webroot Blog

博客园 - 荷梅月剑

分布式应用(Distributed Application) ActiveReports:打印参数设置 ActiveReports 按组分页 在ActiveReport中显示页码 eclipse显示行数 JAVA延时 - 荷梅月剑 - 博客园 初学Java多线程:线程的生命周期 java多线程例子 Api函数声明的格式 - 荷梅月剑 - 博客园 说实话,我更喜欢当一个程序员 Rational Rose 2003 下载及破解方法 不可替代性 爱的链条,让人有所启发的故事 上学与不上学的区别(奇文共赏) Lc.exe已退出,代码为-1 的解决方法 使用UNIQUEIDENTIFIER做为主键 返回值的解决方法 EasyUi tabs的高度与宽度何根据IE窗口的变化自适应 - 荷梅月剑 - 博客园 再回博客园 计算出中文字串的实际长度
jQuery获得各种控件Value的方法
荷梅月剑 · 2010-11-15 · via 博客园 - 荷梅月剑

HTML代码

<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
</asp:RadioButtonList>
<div style="text-align: left">
<a id="btnGetRadioButtonListValue" href="javascript:">通过Type获得RadioButtonList的Value</a>
</div>
<br />
<div style="text-align: left">
<input type="radio" name="radioSelect" value="A" />A<br />
<input type="radio" name="radioSelect" value="B" />B<br />
<input type="radio" name="radioSelect" value="C" />C<br />
<input type="radio" name="radioSelect" value="D" />D<br />
</div>
<div style="text-align: left">
<a id="btnGetRadioValue" href="javascript:">通过Name获得Radio的Value</a>
</div>
<br />
<br />
<div style="text-align: left">
<input type="checkbox" name="chkSelect" value="A" />A<br />
<input type="checkbox" name="chkSelect" value="B" />B<br />
<input type="checkbox" name="chkSelect" value="C" />C<br />
<input type="checkbox" name="chkSelect" value="D" />D<br />
</div>
<div style="text-align: left">
<a id="btnGetCheckBoxValue" href="javascript:">通过Name获得CheckBox的Value</a> <a id="btnSelectAllOn" href="javascript:">全选</a> <a id="btnSelectAllOff" href="javascript:">反选</a>
</div>
<br />
<br />
<div style="text-align: left">
<select id="multiple1" multiple="multiple" style="width: 300px; height: 300px;">
<option value="A1">A1</option>
<option value="A2">A2</option>
<option value="A3">A3</option>
<option value="A4">A4</option>
</select>
</div>
<div style="text-align: left">
<a id="btnGetMultipleValue" href="javascript:">获得Multiple的Value</a> <a id="btnAddMultipleOption" href="javascript:">添加</a> <a id="btnRemoveMultipleOption" href="javascript:">移除</a>
</div>
<br />
<br />
<div style="text-align: left">
<select id="select1">
<option value="B1">B1</option>
<option value="B2">B2</option>
<option value="B3">B3</option>
<option value="B4">B4</option>
</select>
</div>
<div style="text-align: left">
<a id="btnGetSelectValue" href="javascript:">获得Select的Value</a> <a id="btnAddSelectOption" href="javascript:">添加</a> <a id="btnRemoveSelectOption" href="javascript:">移除</a>
</div>

jQuery代码

<script type="text/javascript">
$(document).ready(
function () {
//获得RadioButtonList的Value
$("#btnGetRadioButtonListValue").click(function () {
if ($("input[type=radio]:checked").val() == null) {
alert(
"请选择");
return false;
}
alert($(
"input[type=radio]:checked").val());
});
//获得Html的Radio的Value
$("#btnGetRadioValue").click(function () {
if ($("input[name='radioSelect']:checked").val() == null) {
alert(
"请选择");
return false;
}
alert($(
"input[name='radioSelect']:checked").val());
});
//获得CheckBox的Value
$("#btnGetCheckBoxValue").click(function () {
var values = "";
$(
"input[name='chkSelect']").each(function () {
if ($(this).attr("checked")) {
values
+= $(this).val() + ",";
}
});
if (values == "") {
alert(
"请选择");
return false;
}
values
= values.substring(0, values.length - 1); //去掉尾部,
alert(values);
});
//全选
$("#btnSelectAllOn").click(function () {
$(
"input[name='chkSelect']").each(function () {
$(
this).attr("checked", true);
});
});
//返选
$("#btnSelectAllOff").click(function () {
$(
"input[name='chkSelect']").each(function () {
$(
this).attr("checked", false);
});
});
//获得Multiple的值
$("#btnGetMultipleValue").click(function () {
var values = "";
$(
"#multiple1 option:selected").each(function () {
values
+= $(this).val() + ",";
})
values
= values.substring(0, values.length - 1); //去掉尾部,
alert(values);
});
//添加Multiple的Option
$("#btnAddMultipleOption").click(function () {
$(
"#multiple1").append("<option value='AX'>AX</option>");
});
//移除Multiple所选Option
$("#btnRemoveMultipleOption").click(function () {
$(
"#multiple1 option").remove("option:selected");
});
//获得Select的值
$("#btnGetSelectValue").click(function () {
alert($(
"#select1 option:selected").val());
});
//添加Select的Option
$("#btnAddSelectOption").click(function () {
$(
"#select1").append("<option value='BX'>BX</option>");
});
//移除Select所选Option
$("#btnRemoveSelectOption").click(function () {
$(
"#select1 option").remove("option:selected");
});
});
</script>