今天這個小問題幾乎把我整崩潰
$.each(data.list, function (index, item) { i++; shenhe = "待審核"; tixing = item.Type == "0" ? "判斷題" : "單選題"; if (item.ApprovalState == "N" || item.ApprovalState == "Y") { shenhe = item.ApprovalState == "N" ? "未通過" : "通過"; } $("#questionTable").append('<tr ><td style="display:none">' + item.ID + '</td><td height="32" class="tdd">' + i + '</td><td><a style="color:#39F;width:60px;" href="wyct.html"><div>' + item.Question + '</div></a></td><td>' + tixing + '</td><td>' + shenhe + '</td><td><div>' + item.Advice + '</div></td><td><table style="padding-left:10px;"><tr><td style=" border-top:none; border-right:none; border-bottom:none;"><a style="color:#39F" href="wyct.html">編輯</a></td><td style="border-top: none; border-right:none; border-bottom:none;"><a style="color:#39F;" id="'+item.ID+'" onclick="deleteList('+item.ID+');" >刪除</a></td></tr></table></td><td>' + timeFormatter(item.SubmitTime) + '</td></tr>'); });
以上代碼是我從數據庫獲得了ID值,並且都正確,但是在刪除那兒寫item.ID想傳給deleteList函數就是傳不過去,試了很多種辦法,但是就是在append追加的形式下是傳不過去字符串類型的值的。倒騰一上午后用了
<a style="color:#39F;" id="'+item.ID+'" onclick="deleteList(this.id);" >刪除</a>
成功解決問題。其中的波折心酸就不說了,菜鳥的悲哀啊