0
我想在表格> td中添加文本框,其中复选框被选中,但不起作用。我怎样才能做到这一点?我是jQuery的新手。无法添加带有jQuery按钮的文本框
这是我的代码的html:
<table id="list_lab" class="checkbox-inline">
<tr>
<td><input id="list_lab_0" type="checkbox" name="list_lab$0" checked="checked" value="Electrolyte (Lab)"><label for="list_lab_0">Electrolyte (Lab)</label></td>
</tr><tr>
<td><input id="list_lab_1" type="checkbox" name="list_lab$1" checked="checked" value="Creatinine (plus eGFR)"><label for="list_lab_1">Creatinine (plus eGFR)</label></td>
</tr><tr>
<td><input id="list_lab_2" type="checkbox" name="list_lab$2" value="Blood Urea Nitrogen"><label for="list_lab_2">Blood Urea Nitrogen</label></td>
</tr><tr>
<td><input id="list_lab_3" type="checkbox" name="list_lab$3" value="Complete Blood Count"><label for="list_lab_3">Complete Blood Count</label></td>
</tr><tr>
<td><input id="list_lab_4" type="checkbox" name="list_lab$4" value="Dengue NS1 Ag"><label for="list_lab_4">Dengue NS1 Ag</label></td>
</tr><tr>
<td><input id="list_lab_5" type="checkbox" name="list_lab$5" value="Influenza A/B A/(H1N1) Screening"><label for="list_lab_5">Influenza A/B A/(H1N1) Screening</label></td>
</tr><tr>
<td><input id="list_lab_6" type="checkbox" name="list_lab$6" value="Urine Exam"><label for="list_lab_6">Urine Exam</label></td>
</tr>
这是我的脚本:
$(document).ready(function(){
$('#btn_check').click(function() {
var length = 0;
$('#list_lab').find('tr').each(function(){
var row = $(this);
if(row.find('input[type="checkbox"]').is(':checked')){
$('#list_lab').find(td).append('<input type="text" name="mytext[]" id="txt_row '" + length + "'" />')
}
length++;
});
});
});
谢谢你这么多@manishie。但结果并不像我的我的。我想创建一个文本框,其中输入类型复选框被选中。我该怎么办? – user3001046 2014-10-02 03:04:11
我希望它显示像当我点击复选框然后框是在此输入类型复选框上创建新标签 – user3001046 2014-10-02 03:14:33
对不起,我不明白 – manishie 2014-10-02 03:15:15