如何显示从.val()获得的值 [英] How to display the value get from .val()
本文介绍了如何显示从.val()获得的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在这里有此代码,但是它不起作用...我有一个文本输入,用户可以在其中输入任何数字.当用户单击添加时,它将在表中添加一个新行.当单击删除"时,该行将被删除.
I have this code here but it doesn't work... I have a text input where user can key in any number. When user click on ADD, it will add a new row to the table. when click on REMOVE, that row will be remove.
我想跟踪索引,它正在工作.但是,我还需要跟踪用户输入的数字,然后才能使用该数字删除该行.但是,我无法在表上显示textInput
...不确定哪种显示方法正确.请帮忙.
I want to keep track of the index and it is working. However I need to keep track of the number the user input as well, then I can remove that row with that number. However, I can't get the textInput
to be displayed on the table... not sure what's the right way to display that. Please help.
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();
});
推荐答案
替换此:
$('#status_table').find("#output_newrow_'+textInput+'").remove();
与此:
$('#status_table').find("#output_newrow_" + textInput).remove();
然后重试!
这篇关于如何显示从.val()获得的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文