MVC中jQuery语法的有关问题,function(e).
MVC中jQuery语法的问题,function(e).......a hrefjavascript:void(0) onclickremove(%:Html.Enco
MVC中jQuery语法的问题,function(e).......
<a href="javascript:void(0);" onclick="remove('<%:Html.Encode(row["u_id"].ToString()=="" ? "empty" :row["u_id"].ToString())%>');"></a>
function remove(e) {
if (e != "empty") alert("id is:" + e);
else alert("id is null");
}
问题:根据row["u_id"]是够有值,来执行删除方法。现在是当row["u_id"]为空时,remove(e)的e就为当前页面的URL,row["u_id"]有值的时候e就是id值。(专门写的三元运算,想空值时赋参为:empty。结果还是URL,很是尴尬。。。)
想要的结果:如果row["u_id"]为空的话传给remove(e)的e就为empty,有值的话执行remove方法,弹出e的值。
[最优解释]row["u_id"].ToString()
你可以改成
row["u_id"] == DBNull.Value
试试
[其他解释]e != "empty"换成e != undefined试试
[其他解释]还是一样的是当前链接的URL
[其他解释]不可以哦
[其他解释]自行解决了,谢谢各位!