Javascript 在复选框列表中选中复选框后启用输入字段

Javascript 在复选框列表中选中复选框后启用输入字段,javascript,php,jquery,checkbox,Javascript,Php,Jquery,Checkbox,我有一个从数据库获取的数据列表,我想启用选中复选框上的输入字段。然而,它只适用于第一行。以下是HTML代码: <?php require_once('inc/config.php'); include 'verification/verify_form_details.php'; ?> <html> <head> <title>getElementById example</title> <script t

我有一个从数据库获取的数据列表,我想启用选中复选框上的输入字段。然而,它只适用于第一行。以下是HTML代码:

<?php
    require_once('inc/config.php');
    include 'verification/verify_form_details.php';
?>
<html>
<head>
  <title>getElementById example</title>
  <script type="text/javascript" src="js/jquery-2.1.3.min.js"></script>
</head>
<body>
    <?php 
        $result2 = getProcessID();
    ?>
    <label>Process: <small style="color:red;">*</small>             
    <?php 
        while ($row = mysql_fetch_array($result2))
        {
            $row[0] = cleanOutputData($row[0]);
    ?>      
    <div>       
        <label>
        <input type="checkbox" class="checkbox" name="process[]" id=<?php echo $row[0] ?>  value=<?php echo $row[0]?> /><?php echo $row[0] ?>
        </label>                                        

        <label>
        <input type="text" class="field" disabled name="number[]" id=<?php echo $row[0] ?> />
        </label>

    </div>
    <?php
        }
        mysql_free_result($result2);
    ?>
    </label>
</body>
</html>

getElementById示例
过程:*
/>
和javascript函数:

<script>
    $(document).ready(function () {
            $('.checkbox').change(function() {
                $('.field').attr('disabled',!this.checked)
            });
    });
</script>

$(文档).ready(函数(){
$('.checkbox').change(函数(){
$('.field').attr('disabled',!this.checked)
});
});
你知道我怎么做吗?谢谢

$('.checkbox').change(函数(){
$(this).parent().next().find('.field').prop('disabled',!$(this).is(':checked'))
});

$('.checkbox').change(函数(){
$(this).parent().next().find('.field').prop('disabled',!$(this).is(':checked'))
});


因为相同的
ID
使用类。身份证应该是unique@guradio我尝试了类,现在在按下一个复选框后,它将启用所有字段。编辑了我的问题也使用了
$(this.parent().next().find('.field').attr('disabled',!this.checked)
@guradio现在所有字段都保持禁用状态,即使选中复选框,请参见下面的答案,因为相同的
ID
使用类。身份证应该是unique@guradio我尝试了类,现在在按下一个复选框后,它将启用所有字段。编辑了我的问题也使用了
$(this.parent().next().find('.field').attr('disabled',!this.checked)
@guradio现在所有字段都处于禁用状态,即使选中了复选框。请参见下面的答案