为什么在此cshtml页面上无法在此js函数的上下文中识别id
变量:
function btnDowClick(idE) {
var id = "#Dow" + idE + " ";
var id2 = 1;
$(id).html("<input id='inpDow' class='form-control' onclick='' class='aDow'></input>" +
"<button id='btnCancel' class='btn btn-primary' onClick='btnCancelOnClick(@(id2))'>Cancel</button>");
}
function btnCancelOnClick(id) {
//turn <input> and <button> back into <a>
}
答案 0 :(得分:0)
尝试像这样使用
var id = "Dow" + idE + " ";
$("#"+id).html("<input id='inpDow' class='form-control' onclick='' class='aDow'></input>" +
"<button id='btnCancel' class='btn btn-primary' onClick='btnCancelOnClick(@(id))'>Cancel</button>");
答案 1 :(得分:0)
function btnDowClick(idE) {
var id = "#Dow" + idE + " ";
var id2 = 1;
$(id).html("<input id='inpDow' class='form-control' onclick='' class='aDow'></input>" +
"<button id='btnCancel' class='btn btn-primary' onClick='btnCancelOnClick("+id+")'>Cancel</button>");
}
function btnCancelOnClick(id) {
//turn <input> and <button> back into <a>
}