【发布时间】:2013-04-14 21:18:27
【问题描述】:
假设我有以下代码:
textInput = $('#outputTextInput').val();
$('#outputAdd').click(function(){
$('#status_table tr:last').after('<tr id="output_newrow_"+textInput><td>1</td><td id="type_row_"+textInput>lala</td><td id="num_row_"+textInput>num row '+textInput+'</td><td><img class="image" src="static/OffLamp-icon.png" style="height:64px; width=64px"/></td></tr>');
});
$('#outputRemove').click(function(){
$('#status_table').find("#output_newrow_"+textInput).remove();
});
然后我想调用 ID 为 "output_newrow_"+textInput 或 "type_row_"+textInput 的选择器...
$('#how_should_i_write_it_here').append(textInput)
我不知道我应该怎么称呼那个选择器......
提前感谢所有帮助:)
更新!这是Fiddle 链接。我现在的问题是,当我添加和删除几次时,我无法显示变量“textInput”并且索引号很乱。例如,我键入“1,2,3”,它将在桌子上显示索引 2,3,4。但是当我输入 3 并单击删除时,它会删除索引 2(假设链接到 1)。
【问题讨论】: