How to clear textbox value when checkbox got unchecked in jquery?
<p>I have one datatable (created using jQuery) whose first column contains checkboxes and last column contains textboxes. Since textbox and checkbox are created dynamically, so they have same IDs and names which is as below:</p>

<pre><code>   $('#statement-table').dataTable({
             "data": json,
             "dom": 't',
             "columns": [
                 {"data":""},
                 {"data": "statementCode"},
                 {"data": "dueDate"},
                 {"data": "statementBalance"},
                 {"data": ""}

             ],
             "columnDefs": [
                 {className: "pad-md-left-p-10 pad-top-bottom-p-10 white-active-bg mouse-link", "targets": [0,1,2,3,4]},
                 {
                     'targets':   0,
                     'orderable': false,
                      'render': function(data, type, full, meta) {
                              return '&lt;input type="checkbox" name="payment-checkbox" id="select-checkbox"/&gt;';
                      }
                 },

                  {
                     'targets': 4,
                     'render': function (data, type, full, meta){
                      return
                         '&lt;input type="number" id="payement-textbox" name="text[]" class="payment" value=""/&gt;';
                     }
                  }

             ],
             "aaSorting": [[2, 'desc']],

         }); //End of datatable function 
</code></pre>

<p>My requirement is to clear the textbox value when its corresponding checkbox got unchecked. I have written following jquery code but its not clearing textbox:</p>

<pre><code>    $("input[name=payment-checkbox]").click(function () {
             $("table tr td input[type='checkbox']").each(function () {
                 var ischecked = $(this).is(":checked");
                    if (!ischecked) {
                         $(this).parent().next().find("input[type='text']").val("");
                    }
                    else
                   {
                        alert("do nothing");
                    }
                });
            });
</code></pre>

<p>Please help me with this.</p>