knockout.js Bindings - Text and appearance HTML


Example

This binding updates the innerHTML of the element using jQuery.html(), if jQuery has been referenced, otherwise, KO's own parsing logic. It can be useful if retrieving HTML from an API, RSS feed, etc. Be mindful of using this tag with user input HTML.

page.html

<p>
  <span data-bind="html: demoLink"></span>
</p>

page.js

ko.applyBindings({
  demoLink: ko.observable("<a href='#'>Make a link</a>")
});