1 回答
TA贡献1835条经验 获得超7个赞
您也可以像在 php 代码中使用它一样使用 switch case,如下所示:
success: function(response){
//console.log(response);
$('.sub').html(response.sub);
$('.msg').html(response.msg);
var status = response.status; //Get the value from db;
// if elseif or swithch statetment here//
switch (status) {
case "1":
$('.sts').html('<span class="badge badge-danger">Open</span>');
break;
case "2":
$('.sts').html('<span class="badge badge-secondary">On Hold</span>');
break;
case "3":
$('.sts').html('<span class="badge badge-success">In Progress</span>');
break;
case "4":
$('.sts').html('<span class="badge badge-info">Closed</span> ');
break;
default:
$('.sts').html('<span class="badge badge-danger">Open</span>');
}
}
- 1 回答
- 0 关注
- 98 浏览
添加回答
举报