knockoutjs:Example 1: ifでメッセージの表示・非表示:The if binding

  1. <!DOCTYPE html>
  2. <html lang="ja">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>knockoutjs:Example 1: ifでメッセージの表示・非表示:The if binding</title>
  6. <script type="text/javascript" src="knockout-2.1.0beta.js"></script>
  7. </head>
  8. <body>
  9. <h1>knockoutjs:Example 1: ifでメッセージの表示・非表示:The if binding</h1>
  10. <label><input type="checkbox" data-bind="checked: displayMessage" /> Display message</label>
  11. <div data-bind="if: displayMessage">Here is a message. Astonishing.</div>
  12. <script type="text/javascript">
  13.   ko.applyBindings({
  14.     displayMessage: ko.observable(false)
  15.   });
  16. </script>
  17. <div style="font-size:10pt;text-align:right;margin-top:0.5em;">
  18. <a href="//tips.recatnap.info/" target="_top">PCスキルの小技・忘却防止メモ</a> -
  19. <a href="//tips.recatnap.info/wiki/" target="_top">PCスキルの小技・忘却防止メモのまとめ(wiki)</a>
  20. </div>
  21. <div style="font-size:10pt;text-align:center;margin-top:0.5em;padding:0.5em;border-top:1px solid #ccc;">
  22. Copyright &copy; 2009 by PCスキルの小技・忘却防止メモ. All rights reserved.
  23. </div>
  24. </body>
  25. </html>