Javascript 遍历所有选中的复选框并获取jquery中输入框的值

Javascript 遍历所有选中的复选框并获取jquery中输入框的值,javascript,jquery,html,checkbox,Javascript,Jquery,Html,Checkbox,我有一个代码,表行中有复选框和输入框,我想得到所有复选框被选中的输入框的值 这是html <table> <tr> <td><input type="checkbox" name="new" value="37"></td> <td><input type="text" name="new" id="quantity" class="37"></td> </tr> <tr>

我有一个代码,表行中有复选框和输入框,我想得到所有复选框被选中的输入框的值

这是html

<table>
<tr>
<td><input type="checkbox" name="new" value="37"></td>
<td><input type="text" name="new" id="quantity" class="37"></td>
</tr>

 <tr>
 <td><input type="checkbox" name="new" value="38"></td>
 <td><input type="text" name="new" id="quantity" class="38"></td>
 </tr>
  .....#this continue
   </table>
如何更改它以返回输入框的值

var arr=[];
$(':复选框:选中')。每个(函数(){
arr.push($(this.parent().next().find('input').val())
//arr.push($(this.val())
})
控制台日志(arr)

试试这个:

$(document).ready(function(){
        $( "input[type=checkbox]" ).each(function(){
            if($(this).is(':checked'))
            {
                var value = $(this).closest('tr').find($( "input[type=text]" )).val();
                alert(value);
            }
        });
    });

这将遍历所有函数,但如何序列化函数外部的值。每个函数将它们推送到数组中,然后相应地使用它
$(document).ready(function(){
        $( "input[type=checkbox]" ).each(function(){
            if($(this).is(':checked'))
            {
                var value = $(this).closest('tr').find($( "input[type=text]" )).val();
                alert(value);
            }
        });
    });