14

我试过这个:

<div data-bind="attr: {class: itemSelected? 'selected' : 'unselected' }"></div>

但它不起作用:)

4

2 回答 2

26
于 2012-07-22T18:26:18.787 回答
0

Following worked for me, i was using both css and id attributes, for me it did't work if css attribute is not the first one , so keep css attribute as your fist one.

<div class="panel-collapse collapse" data-bind="css:{in:$index()==0}, attr: { id:'collapse'+$index()} ">

...
...
...

</div>
于 2014-08-04T23:01:17.393 回答