Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Object JavaScript - Show Hide using Knockout
<!DOCTYPE html>
<html xmlns="">
<title>Show Hide</title>
<div data-bind="visible: onoff">Show Me</div>
<button data-bind="click: showMe, disable: onoff">Show Text</button>
<button data-bind="click: hideMe, enable: onoff">Hide Text</button>
<script src="Scripts/knockout-2.2.1.debug.js"></script>
var viewModel = function () {
this.onoff = ko.observable(true); // onoff is intially set to true
hideMe = function() {
showMe = function () {
ko.applyBindings(new viewModel());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment