【问题标题】:Why aren't all of my positive values green and negitives red? [closed]为什么我所有的正面价值观都不是绿色的,而负面价值观不是红色的? [关闭]
【发布时间】:2014-01-13 14:38:44
【问题描述】:

我正在开发商品报价小部件。我已经设置了 'Current' div 和 '24-hour' div,在某一时刻,所有的正值都是绿色的,负值是红色的,但现在这种情况没有发生,而且我经历过的次数也是如此我的脚本,我找不到问题。

这是我的小提琴:http://jsfiddle.net/thetuneupguy/r2Bca/17/

var chngClass = '';
var chnginpercentClass = '';
(obj.Change.substr(0,1) == '+') ? chngClass = 'green' : chngClass = 'red';
(obj.Change.substr(0,1) == '+') ? chnginpercentClass = 'green' : chnginpercentClass = 'red';
$lc.append($('<td class="'+chngClass+'">').text(rndchange || "--"));
$lc.append($('<td class="'+chnginpercentClass+'">').text(rndchpercent || "--"));
   });

【问题讨论】:

  • 请不要提出依赖 JSFiddle 链接才能回答的问题。您需要在问题中包含所有内容

标签: javascript jquery html css json


【解决方案1】:

因为您的样式表中有语法错误:

//These two classes, .red & .green are used to change the font color of values
//depending on the symbol that preceeds the value (+ or -)
.red { color: red; }
.green { color: green; }

这不是您在 CSS 中编写 cmets 的方式。你需要/* */,而不是//。语法错误使其后面的规则无效,.red

http://jsfiddle.net/r2Bca/18/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-02
    • 2015-06-10
    • 2019-05-23
    相关资源
    最近更新 更多