<script>
    $(function() {
    var json = [{ "subject_id": "7"},{ "subject_id": "8"},{ "subject_id": "9"}];    for (var one in json) {
        $("[name='rbl_S" + json[one].subject_id + "']").click(function() {
            if (this.checked) {
                alert(json[one].subject_id);        //执行到这里的时候,总是无法得到正确的subject_id,打印出来的都是最后一个值9,请问应该怎么得到当前操作的subject_id值呢。
            } else {            }
        });
    }
    }
    </script>    
        <ul>
    
        <li style="width:99%;" ><input type="checkbox" name="rbl_S7" id="rbl7_14" value="14_0" /><label for="rbl1_1">市场研究公司/媒体/广告公司</label></li>
        
        <li style="width:99%;" ><input type="checkbox" name="rbl_S7" id="rbl7_15" value="15_1" /><label for="rbl1_1">企业的市场研究/广告/媒体/公关部门</label></li>
        
        <li style="width:99%;" ><input type="checkbox" name="rbl_S7" id="rbl7_16" value="16_2" /><label for="rbl1_1">护肤品生产/销售公司</label></li>
        
        <li style="width:99%;" ><input type="checkbox" name="rbl_S7" id="rbl7_17" value="17_3" /><label for="rbl1_1">以上均无</label></li>
        
    </ul>

解决方案 »

  1.   

                    $.each(json, function(i){
                        $("[name='rbl_S" + json[i].subject_id + "']").click(function(){
                            if (this.checked) {
                                alert(json[i].subject_id); //执行到这里的时候,总是无法得到正确的subject_id,打印出来的都是最后一个值9,请问应该怎么得到当前操作的subject_id值呢。
                            }
                            else {
                            
                            }
                            
                        })
                    });
      

  2.   

    楼上的可以,只是你的html要改成: <li style="width:99%;" ><input type="checkbox" name="rbl_S7" id="rbl7_14" value="14_0" /><label for="rbl1_1">市场研究公司/媒体/广告公司</label></li>
            
            <li style="width:99%;" ><input type="checkbox" name="rbl_S8" id="rbl7_15" value="15_1" /><label for="rbl1_1">企业的市场研究/广告/媒体/公关部门</label></li>
            
            <li style="width:99%;" ><input type="checkbox" name="rbl_S9" id="rbl7_16" value="16_2" /><label for="rbl1_1">护肤品生产/销售公司</label></li>
            
            <li style="width:99%;" ><input type="checkbox" name="rbl_S7" id="rbl7_17" value="17_3" /><label for="rbl1_1">以上均无</label></li>
            
        </ul>