JSFiddle - React, Tailwind, and code Playground
HTML
<!-- This is a *view* - HTML markup that defines the appearance of your UI -->
<p>Name: <strong id="name" data-bind="text: name"></strong></p>
<p>Name: <input data-bind="value: name" /></p>
<p>Click "change" to update the Name in the view (and notice that the value isn't updated).</p>
<button data-bind="click: changeName">Change</button>
JavaScript
// This is a simple *viewmodel* - JavaScript that defines the data and behavior of your UI
function AppViewModel() {
this.name = ko.observable("Jim");
this.changeName = function() {
var text = document.getElementById('name');
text.textContent = 'Bob';
console.log(name());
};
}
// Activates knockout.js
ko.applyBindings(new AppViewModel());