<p>First value: <input data-bind="value: firstValue"></p> <p>First value:<span data-bind="text:firstValue"></span></p> <!-- One-way binding. Populates textbox; syncs only from textbox to model. --> <p>Second value: <input data-bind="value: secondValue"></p> <p>Second value: <span data-bind="text: secondValue"></span></p> <!-- No binding. Populates textbox, but doesn't react to any changes. --> <p>Third value: <input data-bind="value: secondValue.length > 8"></p> <script type="text/javascript"> var viewModel = { firstValue: ko.observable("hello"), // Observable secondValue: "hello, again" // Not observable }; ko.applybindings(viewModel,document.getElementById("eq2")); </script>
以上所述是小编给大家介绍的KnockoutJS 3.X API 第四章之表单value绑定,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!
您可能感兴趣的文章: