动态改变label的文字、样式:
定义一个label 设置label的html(加上id,可以通过id获取,用innerhTML 动态插入html),
//检查项列表下方分数统计
var score = new Ext.form.Label
({
id:"score",
autoShow:true,
autoWidth:true,
autoHeight:true,
hidden:false,
listeners:{
afterrender:function(){
setLabel();
}
},
hideMode:"offsets",//默认display,可以取值:display,offsets,visibility
cls:'',
html:'<span id="score"></span>'//默认""
});
//设置分值统计显示文字 通过调用该方法改变
function setLabel(){
var chaju = differ(tongji); //这是我自己的业务代码,如复制代码记得修改
//score.setText('<font size="+3" color="red">总分值:'+tongji+'分,'+chaju+'</font>');
if(tongji != 100){
tj = '<div style="float:right;"><font size="2em" color="green">总分值: <font size="2em" color="red">'+tongji+'</font>分,'+chaju+'</font></div>';
}
if(tongji == 100){
tj = '<div style="float:right;"><font size="2em" color="green">'+'总分值:'+'<font size="2em" color="red">'+tongji+'</font>分,'+chaju+'</font></div>';
}
document.getElementById('score').innerHTML =tj;
}
效果: