有关如何将条件添加到以下代码段的请求,请帮忙吗?
段:
function ServiceSucceeded(result) {
$('#accNo12').empty();
if (DataType == "json") {
$('#accNo12').append("<div id=\"Search\" class=\"results\">"+
"<span id=\"lb\">Account No:"+result.U_ID+"</span></div>"+
"<label>RelMgr: </label>"+
"<span id=\"RID\">"+result.REL_NAME +"</span><br />"+
"<label>Off ID: </label><span id=\"OffId\">"+ result.SO+"</span><br/>");
}
}
如果需要条件
,我如何在上面的代码段中添加if条件if(result.SO==""){
<label>Off ID: </label><span id=\"OffId\">"+ result.SO+"</span><br/>"
}
else
{
<label>Off ID: </label><span id=\"OffId\">No ID found</span><br/>"
}
感谢您能提供帮助
由于
答案 0 :(得分:1)
function ServiceSucceeded(result) {
$('#accNo12').empty();
if (DataType == "json") {
$('#accNo12').append("<div id=\"Search\" class=\"results\">"+
"<span id=\"lb\">Account No:"+result.U_ID+"</span></div>"+
"<label>RelMgr: </label>"+
"<span id=\"RID\">"+result.REL_NAME +"</span><br />"+
"<label>Off ID: </label><span id=\"OffId\">"+(result.SO || "No ID found")+"</span><br/>");
}
}