一. jQuery-對Radio/CheckBox的操作集合
- jQuery獲取Radio選擇的Value值
-
- $("input[name='radio_name'][checked]").val();
- $("#text_id").focus(function(){
- $("#text_id").blur(function(){
- $("#text_id").select();
- $("input[name='radio_name'][value='要選中Radio的Value值'").
- attr("checked",true);
-
- jQuery獲取CheckBox選擇的Value值
-
- $("input[name='check']:checked");
-
-
- $("input[name='checkbox_name'][checked]");
- Value值你需要遍歷這個集合
- $($("input[name='checkbox_name'][checked]")).
- each(function(){arrChk+=this.value + ',';});
- $("#checkbox_id").attr("checked");
- $("#checkbox_id").attr("checked",true);
- $("#checkbox_id").attr("checked",false);
- $("input[name='checkbox_name']").attr
- ("checked",$("#checkbox_id").attr("checked"));
- $("#text_id").val().split(",");
二. jQuery實現(xiàn)CheckBox全選、全不選
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title>Index</title>
-
- <mce:script src="/Scripts/jquery-1.4.1.js" mce_src="Scripts/jquery-1.4.1.js" type="text/javascript"></mce:script> <mce:script type="text/javascript"><!--
- $(function() {
- $("#CheckAll").click(function() {
- var flag = $(this).attr("checked");
- $("[name=subBox]:checkbox").each(function() {
- $(this).attr("checked", flag);
- })
- })
- })
-
-
-
- </head>
- <body>
- <div>
- <input id="CheckAll" type="checkbox" />
- <input name="subBox" type="checkbox" />
- <input name="subBox" type="checkbox" />
- <input name="subBox" type="checkbox" />
- <input name="subBox" type="checkbox" />
- </div>
- </body>
- </html>