<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www./TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www./1999/xhtml"> <head> <title>Test</title> <script type="text/javascript" src="http://ajax./ajax/libs/jquery/1.6.4/jquery.min.js"></script> <!--script src="jquery.js" type="text/javascript"></script--> </head> <body> <form id="myform"> <input type='checkbox' name='zzfm[]' value='他人介绍 口碑' />他人介绍、口碑 <input type='checkbox' name='zzfm[]' value='价格 优惠活动' />价格、优惠活动 <input type='checkbox' name='zzfm[]' value='商家规模' />商家规模 <input type='checkbox' name='zzfm[]' value='样品品质' />样品品质 <input type='checkbox' name='zzfm[]' value='过场 无要求' />过场,无要求 <input id="other" type='checkbox' name='zzfm[]' value='其它' />其它(请说明) <input type='text' name='zzfmqitatext' disabled='disabled' value='' /> </form> <script type="text/javascript"> $('#myform').click(function(){ var count =0; var checkbox = $('input[type=checkbox]', this); if(checkbox.filter('#other').prop('checked')){ $('input[name=zzfmqitatext]', this).prop('disabled', false); }else{ $('input[name=zzfmqitatext]', this).prop('disabled', true); } var checkedbox = checkbox.filter(function(){ returnthis.checked; }); var uncheckedbox = checkbox.not(checkedbox); if(checkedbox.length >=2){ uncheckedbox.prop('disabled', true); }else{ uncheckedbox.prop('disabled', false); } }); </script> </body> </html |
|
来自: yanjj > 《Javascript》