Get started with knockout CDN

MIT licensed

Knockout is a popular library for creating dynamic, data-bound user interfaces.

Tags:
  • mvvm
  • ui
  • templating

Stable version

Copied!

How to start using knockout CDN


<!DOCTYPE html>
<html>
<head>
    <title>Get started with knockout CDN - cdnhub.io</title>
    <script src="https://cdn.cdnhub.io/knockout/3.5.1/knockout-latest.js"></script>
    <style>
        .highlight { background-color: yellow; }
    </style>
</head>
<body>
    <div data-bind="with: person">
        <p>Name: <input data-bind="value: name" /></p>
        <p>Age: <input data-bind="value: age" /></p>
        <p>Full Name: <span data-bind="text: fullName"></span></p>
    </div>

    <script>
        function Person(name, age) {
            this.name = name;
            this.age = age;

            this.fullName = ko.computed(function() {
                return this.name() + ' (' + this.age() + ')';
            }, this);
        }

        const person = new Person('John Doe', 30);

        ko.applyBindings(person);
    </script>
</body>
</html>
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!

All versions