Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/412.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何显示从.val()获取的值_Javascript_Jquery_Html Table - Fatal编程技术网

Javascript 如何显示从.val()获取的值

Javascript 如何显示从.val()获取的值,javascript,jquery,html-table,Javascript,Jquery,Html Table,我这里有这个代码,但它不工作。。。我有一个文本输入,用户可以输入任何数字。当用户单击ADD时,它将向表中添加新行。单击“删除”时,该行将被删除 我想跟踪索引,它正在工作。但是,我还需要跟踪用户输入的数字,然后我可以删除带有该数字的行。但是,我无法在表上显示textInput。。。我不确定用什么方式来显示。请帮忙 var index=1; textInput = $('#outputTextInput').val(); $('#outputAdd').click(function(){

我这里有这个代码,但它不工作。。。我有一个文本输入,用户可以输入任何数字。当用户单击ADD时,它将向表中添加新行。单击“删除”时,该行将被删除

我想跟踪索引,它正在工作。但是,我还需要跟踪用户输入的数字,然后我可以删除带有该数字的行。但是,我无法在表上显示
textInput
。。。我不确定用什么方式来显示。请帮忙

 var index=1;
 textInput = $('#outputTextInput').val();

 $('#outputAdd').click(function(){
                   index++;
                   $('#status_table tr:last').after('<tr id="output_newrow_'+textInput+'"><td>'+index+'</td><td id="type_row_'+index+'">type_row_'+textInput+'</td><td id="num_row_'+index+'">num row '+index+'</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();
               });
var指数=1;
textInput=$('#outputOutput').val();
$('#outputAdd')。单击(函数(){
索引++;
$(“#status_table tr:last”)。之后(“”+索引+”键入_行“+”文本输入+”num行“+索引+”);
});
$('#outputRemove')。单击(函数(){
$('#status_table')。查找('#output_newrow'+textInput+')。删除();
});
替换此:

$('#status_table').find("#output_newrow_'+textInput+'").remove();
为此:

$('#status_table').find("#output_newrow_" + textInput).remove();
再试一次

替换这个:

$('#status_table').find("#output_newrow_'+textInput+'").remove();
为此:

$('#status_table').find("#output_newrow_" + textInput).remove();

再试一次

耶,它工作了!但是我如何为这种类型显示它呢?它将显示为type_row_textInput…我想在表中显示它,但该行显示“#type_row_”+索引无法正确获取。您可以将其作为更新添加到问题中,并提供更多解释!就像你给我看的代码($(“#status_table”).find(“#type_row_uu”+index.show()”)在屏幕上逐字逐句地打印了这个“#type_row_uu”+index”。真管用!但是我如何为这种类型显示它呢?它将显示为type_row_textInput…我想在表中显示它,但该行显示“#type_row_”+索引无法正确获取。您可以将其作为更新添加到问题中,并提供更多解释!正如你给我看的代码($(“#状态#表”).find(#type#u row#+index.show();)在屏幕上逐字打印了这个“#type#u row#+index”。