业务场景:当一行中有一个CheckBox被选中,则为此行添加class。
<script type="text/javascript"> $(function(){ $("input[type='radio']").click(function(){ $(this).parent("td").parent("tr").addClass("info"); }); $("input[type='checkbox']").click(function(){ var s = $("input[name='name']"); var boxChecked=false; s.each(function(i) { if(this.checked==true){ boxChecked=true; } }); if(boxChecked){ $(this).parent("td").parent("tr").addClass("info"); }else{ $(this).parent("td").parent("tr").removeClass("info"); } }); }); </script>