JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://github.com/greenlaw110/knockout/raw/master/build/output/knockout-latest.js"></script>
<script src="https://github.com/greenlaw110/knockout-ext/raw/master/build/output/knockout-ext-latest.js"></script>
<label>First name: </label>
<input type="text" data-bind="event: {change: onChange},
attr: {
name: controlName,
title: 'please input ' + controlName + ' here'
},
className: className"></input>
<input type="text" data-bind="event: {change: onChange},
attr: {
name: controlName,
title: 'please input ' + controlName + ' here'
},
className: className"></input>
JavaScript
var viewModel = {
controlName: "firstname",
onChange: function(){alert("firstname changed");},
className: function() {return 'firstname, requried';}
};
ko.applyBindings(viewModel);