Title taken from here. For my example I did it with input.
Html:
<!DOCTYPE html> <html> <head> <script type="text/javascript" src="/knockout-3.2.0.js"></script> <script type="text/javascript" src="/index.js"></script> </head> <body onload="ko.applyBindings(viewModel)"> <input type="checkbox" placeholder="I am a test" data-bind="click: inputClick"></input> </body> </html>
JS:
var viewModel = { inputClick: function() { alert("just clicked input"); return true; } }
Here note return true. Without that state will not change (i.e. if for input you write type="checkbox")
Download from here.