The following will do the job for you. This is not ideal, but should give you a platform for work.
First, everything in Knockout is tied to a view model. You want to be able to control the visibility of the 3 sections, so here is a presentation model that might work. As I said, not perfect :)
var buttonVm = new function(){ var self = this;
You will need to change the markup to: -
<button type="button" data-bind="click: toggle1">Button 1</button> <button type="button" data-bind="click: toggle2">Button 2</button> <button type="button" data-bind="click: toggle3">Button 3</button> <div data-bind="visible: button1Visible"> Div 1 </div> <div data-bind="visible: button2Visible"> Div 2 </div> <div data-bind="visible: button3Visible"> Div 3 </div>
A few things to note here. First, I added a type attribute. Without it, the default button behavior will be to try to submit your form.
The plot of all: -
// Create view model var vm = new buttonVm(); ko.applyBindings(vm);
source share