我正在製作一個小型的個人應用程序,用jQuery創建html表格。我有這個腳本(我從這裏的某個地方借用並調整了一下),只需點擊一下按鈕,在我的表格末尾添加一個新列。jQuery腳本運行不正確
function addJSONKey(){
var first = true;
$('#jsonTable').find('tr').each(function(){
$(this).find('th').eq(-1).after(
'<th contentEditable>New Key</th>'
);
if(first === true){
first = false;
// the function does not execute this statement
// even though the debugger breaks here.
$(this).find('td').eq(-1).after(
'<td>Frist</td>'
);
} else {
$(this).find('td').eq(-1).after(
'<td contentEditable>Not First</td>'
);
}
});
}
我想什麼腳本做的是,第一行是比其他人不同,但如果我運行該腳本,它無處不在,還給不是第一排。
如果您不想爲其他行「