用jquery异步加载一个list集合,集合中为空的值我想直接显示空而不是undefined
我想空值就直接显示空而不是undefined,下面是我的js代码function(data){vartmp=eval(data);for(vari=0;i<tmp.len...
我想空值就直接显示空而不是undefined,
下面是我的js代码
function(data){
var tmp = eval(data);
for(var i = 0 ; i < tmp.length ; i ++){
$("#tab").append("<tr >"
+"<td><div class = 'textFlow' title = "+tmp[i].sourceExplain+" id = "+a+">"+tmp[i].sourceExplain+"</div></td>"
+"<td><input type='button' class='show_jl_btn' value='举例' onclick='show_jlmodel("+i+")'/><div class='jlval'><input type = 'hidden' value = "+tmp[i].sourceExample+" id = '"+i+"se'/></div> </td>"
+"<td><div class = 'textFlow' title = "+tmp[i].sourceAudioName+">"+tmp[i].sourceAudioName+"</td>"
+"<td><div class = 'textFlow' title = "+tmp[i].sourceVidoName+">"+tmp[i].sourceVidoName+"</td>"
+"</tr>");
} 展开
下面是我的js代码
function(data){
var tmp = eval(data);
for(var i = 0 ; i < tmp.length ; i ++){
$("#tab").append("<tr >"
+"<td><div class = 'textFlow' title = "+tmp[i].sourceExplain+" id = "+a+">"+tmp[i].sourceExplain+"</div></td>"
+"<td><input type='button' class='show_jl_btn' value='举例' onclick='show_jlmodel("+i+")'/><div class='jlval'><input type = 'hidden' value = "+tmp[i].sourceExample+" id = '"+i+"se'/></div> </td>"
+"<td><div class = 'textFlow' title = "+tmp[i].sourceAudioName+">"+tmp[i].sourceAudioName+"</td>"
+"<td><div class = 'textFlow' title = "+tmp[i].sourceVidoName+">"+tmp[i].sourceVidoName+"</td>"
+"</tr>");
} 展开
2个回答
展开全部
function(data) {
var tmp = eval(data);
for (var i = 0; i < tmp.length; i++) {
$("#tab").append("<tr >" + "<td><div class = 'textFlow' title = " + tmp[i].sourceExplain + " id = " + a + ">" + tmp[i].sourceExplain + "</div></td>" + "<td><input type='button' class='show_jl_btn' value='举例' onclick='show_jlmodel(" + i + ")'/><div class='jlval'><input type = 'hidden' value = " + tmp[i].sourceExample + " id = '" + i + "se'/></div> </td>" + "<td><div class = 'textFlow' title = " + tmp[i].sourceAudioName + ">" + tmp[i].sourceAudioName + "</td>" + "<td><div class = 'textFlow' title = " + tmp[i].sourceVidoName + ">" + tmp[i].sourceVidoName + "</td>" + "</tr>");
var html = $("#tab").html().replace(new RegExp("undefined","g"),"");
$("#tab").html(html);
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询