CSS样式:
<style type="text/css">
.icon-red, .icon-green
{
width:17px;height:12px;overflow:hidden;margin:auto;
background:url(d_2.gif) no-repeat;
text-align:center;
display:block;
}
.icon-green{
background:url(d_1.gif) no-repeat;
}
</style>
表单
<table>
<tr>
<td style="width:25%;height:20px;margin-left:20px">CM 状态:</td>
<td style="width:25%;height:20px;margin-left:20px"><span id="cm_status"></span></td>
<td style="width:25%;height:20px;margin-left:20px">CM 重启次数统计:</td>
<td style="width:25%;height:20px;margin-left:20px"><span id="cm_restart" style="color:#a31515"></span></td>
</tr>
</table>
js代码
function SetData(data) {
if (data.action == "load_cm_info") {
//跨页面传递的数据对象,克隆后才可以安全使用
data = mini.clone(data);
$("#cm_mac").html(data.id);
}
$.post(base_url+"twcore/index.php/cm_search/get_cm", {cm_mac:$("#cm_mac").val()}, function(data){
eval("var asd = {" + data + "}");
if(asd.cm_status=='1'){
$("#cm_status").html("<span class='icon-red'></span>");
}
if(asd.cm_status=='6'){
$("#cm_status").html("<span class='icon-green'></span>");
}else{
$("#cm_status").html("<span class='icon-red'></span>");
}
});
}
效果如下