【发布时间】:2015-06-14 02:54:05
【问题描述】:
我正在尝试根据我从 js 文件中获取的值更改 div 的背景。
因此,如果该值与 0 不同,我想要一个背景,如果它为 0,我想要另一个背景。
这是我正在尝试的标记:
<tbody data-bind="foreach: skills">
<tr>
<td>
<div data-bind="attr: { id: Id }, style: { background: Outstanding != '0' ? 'none repeat scroll 0 0 #B33A3A;' : 'none repeat scroll 0 0 #396eac;' }">
<span data-bind="text: Name" style="color: #ffffff;"></span>
</div>
<div>
<span data-bind="visible: Outstanding != '0', text: Outstanding + ' Needed'" style="color: #365474"></span><br/>
<span data-bind="text: Employees" style="color: #365474"></span>
</div>
</td>
</tr>
</tbody>
你们看到这里有什么不正确的地方吗?
PS。使用 Chrome 插件 Knockoutjs 上下文调试器,我可以看到 Outstanding 的实际值为 0:
【问题讨论】:
标签: javascript jquery css knockout.js knockout-2.0