Search code examples
htmlinternet-explorerbackground-colorinline-formset

dynamic background-color not working in IE


I need background-colors that change based on user input, but it isn't working in IE.

Am I doing it wrong? Is there a workaround?

Example: http://jsfiddle.net/3nx7G/1/

var viewModel = {
    color: ko.observable("red")
};

ko.applyBindings(viewModel);

<span style="background-color: red">red</span> <span style="background-color: green">green</span><br/>
<input data-bind="value: color" />
<span data-bind="text: color, style: { 'background-color': color }"></span>

Solution

  •     Try using
       <span data-bind="text: color, style: { backgroundColor: color }"></span>. 
    

    Hyphen in the javascript is not valid use javascript equivalent like here