Today, this little problem almost breaks my whole.
$.each (data.list, function (index, item) {i++; Shenhe = "Pending Review"; tixing = Item. Type = = "0"? "Judgment question": "Single Choice"; if (item. Approvalstate = = "N" | | Item. Approvalstate = = "Y") {Shenhe = Item. Approvalstate = = "N"? "Failed": "Passed"; } $ ("#questionTable"). Append ('<TR><TDstyle= "Display:none">' + item.id + '</TD><TDHeight= "+"class= "TDD">' + i + '</TD><TD><astyle= "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><Tablestyle= "padding-left:10px;"><TR><TDstyle= "border-top:none; border-right:none; Border-bottom:none; "><astyle= "COLOR: #39F"href= "wyct.html">Edit</a></TD><TDstyle= "border-top:none; border-right:none; border-bottom:none;"><astyle= "color: #39F;"ID= "' +item.id+ '" onclick= "deletelist (' +item.id+ ');" > Delete </a ></TD></TR></Table></TD><TD>' + timeformatter (item. Submittime) + '</TD></TR>'); });
The above code is I get the ID value from the database , and both are correct, but write the item in the delete there. ID want to pass to the DeleteList function is not passed, tried a lot of ways, but in the form of append append is not passed the string type value. Daoteng used it after a morning.
<a style= "color: #39F;" id= "' +item.id+ '" onclick= "deletelist (this.id);" > Delete </a>
Solve the problem successfully. One of the twists and turns sad not to say, Rookie of sorrow Ah
Append <tr> ID parameter to JS function from append