zoukankan      html  css  js  c++  java
  • Knockout.js hasFocus

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
        <script src="js/jquery-1.11.1.min.js"></script>
        <script src="js/knockout-3.3.0.js"></script>
        <script type="text/javascript">
    
            function PersonViewModel(name) {
                // Data
                this.name = ko.observable(name);
                this.editing = ko.observable(false);
    
                // Behaviors
                this.edit = function () { this.editing(true) }
            }
    
            $(function () {
                ko.applyBindings(new PersonViewModel("Bert Bertington"));
            })
        </script>
    </head>
    <body>
        <p>
            Name: 
        <b data-bind="visible: !editing(), text: name, click: edit">&nbsp;</b>
            <input data-bind="visible: editing, value: name, hasFocus: editing" />
        </p>
        <p><em>Click the name to edit it; click elsewhere to apply changes.</em></p>
    </body>
  • 相关阅读:
    Jenkins安装后,安装插件失败。报错SunCertPathBuilderException
    计算机网络
    abaqus
    品优购
    html5 css3
    css定位
    元素的显示与隐藏 / 精灵图
    学成在线案例
    css(3)
    css(2)
  • 原文地址:https://www.cnblogs.com/YuanSong/p/4737033.html
Copyright © 2011-2022 走看看