码迷,mamicode.com
首页 > Web开发 > 详细

Knockout.js CSS绑定

时间:2015-08-17 15:23:06      阅读:751      评论:0      收藏:0      [点我收藏+]

标签:

<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>
    <style>
        .b_b
        {
            background-color: blue;
        }
    </style>
    <script type="text/javascript">
        var viewModel = {
            currentProfit: ko.observable(1) // Positive value, so initially we don‘t apply the "bb" class
        };
        $(function () {
            viewModel.currentProfit(-1); // Causes the "bb" class to be applied
            ko.applyBindings(viewModel);
        })
    </script>
</head>
<body>
    <div data-bind="css: { ‘b_b‘: currentProfit() < 0 }">
        Profit Information
    </div>
</body>

 

Knockout.js CSS绑定

标签:

原文地址:http://www.cnblogs.com/YuanSong/p/4736590.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!