【发布时间】:2016-05-10 06:50:10
【问题描述】:
$(function() {
var m_row = 0;
$("body").on("click", "#m_add", function() {
console.log("click lagche");
var result = "0";
var row;
row = '<tr id="row_' + m_row + '">';
var clone = $("#m_input_file").clone();
clone.attr('id', "");
clone.attr('name', "m_input_file" + m_row);
row += '<td id="file_' + m_row + '"></td>';
row += '<td><input type="hidden" name="m_sl[]" value="' + m_row + '"></td>';
row += '</tr>';
$("#workmanship_check table tbody").prepend(row);
console.log(clone);
$("#file_" + m_row).html(clone);
m_row++;
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id="workmanship_check" >
<thead>
<tr>
<th>
<input type="file" id="m_input_file">
</th>
<th><a href="#" id="m_add">Add</a></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
它可以在 Mozilla firefox 浏览器中运行,但不能在 Chrome 中运行。
有什么办法吗?
如果不是,请建议我如何动态添加输入文件的值?
【问题讨论】:
-
不工作是什么意思?
-
不起作用是什么意思?
标签: javascript jquery google-chrome