Javascript 在复选框上添加动态行和数据单击

Javascript 在复选框上添加动态行和数据单击,javascript,jquery,Javascript,Jquery,我再次遇到jQuery问题,希望能得到一些帮助 我有一系列的复选框,看起来像以下两个: <input type="checkbox" name="MultiPointInspection" id="MultiPointInspection" class="MultiPointInspection" value="<?php echo $MultiPointInspection; ?>" onKeyPress="return disableEnterKey(event)" rel

我再次遇到jQuery问题,希望能得到一些帮助

我有一系列的复选框,看起来像以下两个:

<input type="checkbox" name="MultiPointInspection" id="MultiPointInspection" class="MultiPointInspection" value="<?php echo $MultiPointInspection; ?>" onKeyPress="return disableEnterKey(event)" rel="Multi Point Vehicle Inspection" />&nbsp;Multi Point Vehicle Inspection<br />
<input type="checkbox" name="TireRotationandBrake" id="TireRotationandBrake" class="TireRotationandBrake" value="<?php echo $TireRotationandBrake; ?>" onKeyPress="return disableEnterKey(event)" />&nbsp;Tire Rotation and Brake Inspection<br />
这是在另一个按钮上添加行的常规代码单击:

$("document").ready(function(){
    $(".alternativeRow").btnAddRow({oddRowCSS:"oddRow",evenRowCSS:"evenRow"});
    $(".delRow").btnDelRow();
});
好像我的要求还不够,我还想做的是不要为这些行添加最后一列。最后一列包含删除该行的链接,我只希望在取消选中复选框时删除该行

我已经创建了一个关于问题的基本设置(注意javascript包含完整的jQuery表AddRow插件代码),如果能得到任何帮助,我将不胜感激


谢谢。

我建议改用
change
。试试像这样的东西

$("#MultiPointInspection,#TireRotationandBrake").on('change', function() {
    if ($(this).is(':checked')) {
        $('<tr><td><input type="text" id="'+$(this).attr("id")+'" 
              class="'+$(this).attr("class")+'" name="'+$(this).attr("name")+'"/>
                     </td></tr>').appendTo("#atable");
    }
    else {
        $('input#'+$(this).attr("id")+'[type="text"]').remove();
    }
});
$(“#多点检测,#轮胎磨损和制动”)。打开('change',function(){
如果($(this).is(':checked')){
$('
)。附于(“#atable”);
}
否则{
$('input#'+$(this.attr(“id”)+'[type=“text”]').remove();
}
});

小提琴:

我建议改用
change
。试试像这样的东西

$("#MultiPointInspection,#TireRotationandBrake").on('change', function() {
    if ($(this).is(':checked')) {
        $('<tr><td><input type="text" id="'+$(this).attr("id")+'" 
              class="'+$(this).attr("class")+'" name="'+$(this).attr("name")+'"/>
                     </td></tr>').appendTo("#atable");
    }
    else {
        $('input#'+$(this).attr("id")+'[type="text"]').remove();
    }
});
$(“#多点检测,#轮胎磨损和制动”)。打开('change',function(){
如果($(this).is(':checked')){
$('
)。附于(“#atable”);
}
否则{
$('input#'+$(this.attr(“id”)+'[type=“text”]').remove();
}
});
小提琴:

$("#MultiPointInspection,#TireRotationandBrake").on('change', function() {
    if ($(this).is(':checked')) {
        $('<tr><td><input type="text" id="'+$(this).attr("id")+'" 
              class="'+$(this).attr("class")+'" name="'+$(this).attr("name")+'"/>
                     </td></tr>').appendTo("#atable");
    }
    else {
        $('input#'+$(this).attr("id")+'[type="text"]').remove();
    }
});