knockout.js Attr


Example

Use the attr binding to apply any additional attributes to your element. Most commonly used for setting an href, src, or any data-attributes.

<img data-bind="attr: { src: url, title: title }"/>
var viewModel = {
    url: ko.observable("images/example.png"),
    title: "example title"
};