如何在javascript中更改字体颜色红色 [英] How to change font color red in javascript
本文介绍了如何在javascript中更改字体颜色红色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在javascript中有这个方法
var ModifiedNumericValueWithDecimal = function( value ,元数据,记录){
if ( value == null || value == ' undefined') return ' ';
if (isNaN( value )) return value ;
if ( value < 0 ){
return ( + Math.abs( value )+ );
}
if (parseFloat( value )> parseFloat( 0 。 0 )){
< span class =code-keyword> return Ext.util.Format.number( value ,' 0,000,000');
}
其他 返回 值跨度>;
};
i想要它返回
返回(+ Math.abs(value)+);
值为shoule为红色
解决方案
这可能对你有所帮助
< p style = 颜色:#f00;>
<%= ModifiedNumericValueWithDecimal>
< / p >
至少有两种方式:)
首先:
1.使用颜色创建CSS类:红色
。 red-text {颜色 : 红色; }
2.需要时将其添加到元素中
( #your-element)。addClass( < span class =code-string> red-text);
同样打电话
i have this method in javascript
var ModifiedNumericValueWithDecimal = function (value, metadata, record) {
if (value == null || value == 'undefined') return '';
if (isNaN(value)) return value;
if (value < 0) {
return "(" + Math.abs(value) + ")";
}
if (parseFloat(value) > parseFloat(0.0)) {
return Ext.util.Format.number(value, '0,000,000');
}
else return value;
};
i want that when it return
return "(" + Math.abs(value) + ")";
thn value shoule be in red color
解决方案
this might help you
<p style="color : #f00;"> <%=ModifiedNumericValueWithDecimal> </p>
At least couple of ways :)
First:
1. create CSS class with color: red
.red-text { color: red;}
2. add it to your element when needed
("#your-element").addClass("red-text");
similarly call
这篇关于如何在javascript中更改字体颜色红色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文