I need to add two classes to an element using the css binding.
For example:
<div class="animal" data-bind="css: mammal, dog"></div>
However this only adds the first class, "mammal".
Please could you tell me what I'm doing wrong. Thanks
Try this:
<div class="animal" data-bind="css: {mammal:true, dog:true}"></div>
See documentation
you can also use a string like this:
<div class="animal" data-bind="css:{'mammal dog':true}"></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With