Javascript logo

Some notes about creating visible and invisible buttons in Knockout.js.

Initialize Boolean variable as observable and set it's value equal to false:

self.displayTopButton = ko.observable(false);

Set value equal to False:


Set value equal to True:


Show/hide button according to Boolean value:

<div class="button" data-bind="if: displayTopButton, click: GoUp">Наверх</div>

The button will be shown only when "displayTopButton" is equal to false.