Re: 請問有關jquery抓checkbox的問題?

看板Ajax作者 (愁痕飄絮)時間17年前 (2008/07/10 19:39), 編輯推噓0(002)
留言2則, 1人參與, 最新討論串1/1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "" rel="nofollow">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="" rel="nofollow">http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Checkbox Test</title> <script src="http://www.google.com/jsapi" type="text/javascript"></script> <script type="text/javascript">//<![CDATA[ google.load('jquery', '1.2.6'); //]]></script> </head> <body> <form> <input type="checkbox" id="FCHK" name="F_CHK[]" value="AA" /> <input type="checkbox" id="FCHK1" name="F_CHK[]" value="BB" /> <input type="checkbox" id="FCHK2" name="F_CHK2[]" value="CC" /> <input type="checkbox" id="FCHK3" name="F_CHK2[]" value="DD" /> </form> <script type="text/javascript"> (function($){ var chk1 = ''; var which = ''; $("input[@name='F_CHK[]']").each(function(){ chk1 += $(this).val() + ', '; if ( $(this).attr('checked') ){ which = $(this).attr('id'); } }); alert('走訪F_CHK[]' + chk); alert(which + '被勾選'); })(jQuery); </script> </body> </html> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.117.202.109

07/10 19:40, , 1F
你可以對 value="BB" 那個input 加個 checked="checked"
07/10 19:40, 1F

07/10 19:40, , 2F
就可以測被勾選了
07/10 19:40, 2F
文章代碼(AID): #18TVJhVs (Ajax)
文章代碼(AID): #18TVJhVs (Ajax)