O'Reilly logo

Getting Started with Knockout.js for .NET Developers by Andrey Akinshin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Text and appearance bindings

Knockout.js provides you with a huge number of useful HTML data bindings to control the text and its appearance. In Chapter 1, Introduction to Knockout.js, we discussed what bindings are and how we can use them. In this section, we take a brief look at the most common ones:

  • The text binding
  • The html binding
  • The css binding
  • The style binding
  • The attr binding
  • The visible binding

The text binding

The text binding is one of the most useful bindings. It allows us to bind text of an element (for example, span) to a property of the ViewModel. Let's create an example in which a person has a single firstName property (PersonalPage-Binding-Text1.html).

The Model will be as follows:

var person = {
  firstName: "John"
};

The ViewModel will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required