当用户在表格中添加一行时,它应该在每一行的“图像”列下显示输入"file"功能,以便用户可以为每一行选择一个文件。但是当我添加一行时,它不会在行内显示文件输入。
下面是html代码:
<table id="qandatbl" border="1">
<tr>
<th class="image">Image</th>
</tr>
</table>
下面是jquery代码
function insertQuestion(form) {
var $tr = $("<tr></tr>");
var $image = $("<td class='image'></td>");
function image(){
var $this = $(this);
var $imagefile = $("<input type='file' name='imageFile' id='imageFile' />").attr('name',$this.attr('name'))
.attr('value',$this.val())
$image.append($imagefile);
};
$tr.append($image);
$('#qandatbl').append($tr);
}
最佳答案
我在任何地方都看不到对内部函数 image()
的调用。更多关于为什么你有这样的内部功能?解决这个问题很可能会解决您的问题。
关于javascript - 如何在新行中添加输入类型 "file"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8646123/