我正在從onclick事件調用名爲edit的函數,如下所示。Javascript錯誤:未捕獲ReferenceError:未定義編輯
<script type="text/javascript">
$(document).ready(function() {
...
$.each(data, function (key, val) {
...
var td11 = $('<input type="button" value="Edit" onclick="edit();" />')
.attr("name",val.Id);
$(tr2).append(td11);
$(table1).append(tr2);
});
$("#cers").append(table1);
的功能是在$。每個循環外定義,內部$(文件)。就緒,如下
function edit() {
alert("Id ");
}
當我點擊編輯按鈕,鉻所示錯誤:未捕獲的ReferenceError:編輯沒有定義。
沒有其他錯誤。
是否有控制檯內的任何其他錯誤? –
請嘗試在jsfiddle.net中重現錯誤請 –
我明白了。 *劃傷下巴* –