JQuery ÅжÏcheckboxÊÇ·ñÑ¡ÖУ¬checkboxÈ«Ñ¡£¬»ñÈ¡checkboxÑ¡ÖÐÖµ
JQueryÊÇÒ»¸ö·Ç³£ÈÝÒ×ÉÏÊֵĿò¼Ü£¬µ«ÊÇÓкܶණÎ÷ÐèÒªÎÒÃÇÉîÈëѧϰµÄ¡£
ÅжÏ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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>JQuery ÅжÏcheckboxÊÇ·ñÑ¡ÖУ¬checkboxÈ«Ñ¡£¬»ñÈ¡checkboxÑ¡ÖÐÖµ</title> <script type="text/javascript" language="javascript" src="http://code.jquery.com/jquery-1.6.4.min.js" ></script> <script type="text/javascript"> $(function(){ /*------------ È«Ñ¡/È«²»Ñ¡ ------------*/ $('#cboxchecked').click(function(){ //ÅжÏappleÊÇ·ñ±»Ñ¡ÖÐ var bischecked=$('#cboxchecked').is(':checked'); var fruit=$('input[name="fruit"]'); bischecked?fruit.attr('checked',true):fruit.attr('checked',false); }); /*------------- »ñÈ¡Ñ¡ÖÐÖµ -------------*/ $('#btn_submit').submit(function(){ $('input[name="fruit"]:checked').each(function(){ var sfruit=$(this).val(); alert(sfruit); }); return false; }); }) </script> </head> <body> <form action=""> <input type="checkbox" /> <label for="cboxchecked">È«Ñ¡/È«²»Ñ¡</label> <br /> <br /> <input type="checkbox" value="apple" /> <label for="apple">Apple</label> <input type="checkbox" value="orange" /> <label for="orange">Orange</label> <input type="checkbox" value="banana" /> <label for="banana">Banana</label> <input type="checkbox" value="grapes" /> <label for="grapes">Grapes</label> <br /> <br /> <input type="submit" value="submit" /> </form> </body> </html>
posted @
¡¡