我有一个用jquery创建的输入文本,现在我试图在按钮被按下时获取输入文本的值,但它返回未定义:
这就是我想要做的:
$("#" + value).val(); \\value is 'ABC-123'
下面是我通过jQuery创建的输入文本:
html += '<td><input type="text" name="' + key + '-' + taskArray[i] + '" id="' + key + '-' + taskArray[i] + '" class="vendorDropdown" value="' + value.baseOrSchedStartList[i] + '" /></td>'; //key is ABC, taskArray[i] is 123 and value.baseOrSchedStartList[i] is the value, if its blank then in the input it will return just value我做错了什么?当我在输入文本中输入文本时,我希望它就是值。
这是一个小麻烦,https://jsfiddle.net/22dg6oyr/,但是我不能让jquery运行它。
发布于 2015-05-27 04:10:56
您的第二个代码片段将生成如下内容:(注意ABC和123之间的连字符)
<td><input type="text" name="ABC-123" id="ABC-123" class="vendorDropdown" /></td>发布于 2015-05-27 04:11:41
您创建的文本元素的名称为"ABC-123“(注意连字符)。如果值是"ABC123“(没有连字符),那么它将不匹配任何元素。
https://stackoverflow.com/questions/30467900
复制相似问题