edhedges
edhedges

Reputation: 2718

Why does knockout not change the value attribute when updating value of input type text?

Title pretty much says it all. I'm just wondering if anyone would know why the value binding on knockout doesn't create/set a value attribute on the input element in the document.

Upvotes: 0

Views: 220

Answers (1)

jfriend00
jfriend00

Reputation: 707326

Per request, making my comment into an answer:

The value attribute on an <input value="foo"> element is the initial value of the field. Once active in the page, the .value property is the current value. Attribute and property are not the same.


If you have some flawed piece of code (e.g. the printing plugin) that you're trying to work with that is using the attribute instead of the property, then I supposed you could set the attribute to match the property before calling that printing plugin or you could path the printing plugin to correctly access the property.

Upvotes: 1

Related Questions