JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://ajax.aspnetcdn.com/ajax/knockout/knockout-2.2.1.js"></script>
Profit:
<span id="profitPercentage"
data-bind="text: profit, style: { color: (profit()<10)?'Red':'Green' }">
</span>
<input id='inpName' data-bind="text: profit" />
CSS
body
{
font-family: Arial;
}
JavaScript
// Style Binding
// Our viewmodel with observables
function viewmodel() {
//self = this;
this.profit = ko.observable($('#inpName').val());
}
// Runs at document load
$(document).ready(function(){
// Create an instance of the viewmodel
var myViewmodel = new viewmodel();
// Bind the instance to the view
ko.applyBindings(myViewmodel);
});