knockout.js Observables Creating an observable


Example

JS

// data model
var person = {
    name: ko.observable('Jack'),
    age: ko.observable(29)
};

ko.applyBindings(person);

HTML

<div>   
    <p>Name: <input data-bind='value: name' /></p> 
    <p>Age: <input data-bind='value: age' /></p> 
    <h2>Hello, <span data-bind='text: name'> </span>!</h2>  
</div>