checkbox radio select綁定

index11.htmlhtml

<html><head>    <title>checkbox radio select綁定</title>    <script src="jquery-1.11.2.min.js"></script>    <script src="groot.js"></script></head><body><div gt-view="myview">    <span gt-text="{name}"></span>    <select gt-select="name">        <option value="李四">李四</option>        <option value="張三">張三</option>    </select>    <br>    <br>    <div>        <div gt-text="{s}"></div>        <input gt-radio="s" type="radio" value="清華" name="school">清華        <input gt-radio="s" type="radio" value="北大" name="school">北大        <input gt-radio="s" type="radio" value="復旦" name="school">復旦    </div>    <br>    <br>    <div gt-each="l">        <span gt-text="{name}"></span>    </div>    <div gt-each="c">        <span><input type="checkbox" gt-check="s" gt-click="click"><span gt-text="{name}"></span></span>    </div></div></body></html><script>    var view = groot.view("myview", function (vm, ve) {        vm.name = "張三"        vm.s = "北大";        vm.l=[];        vm.c = [{"name": "張三", s: false}, {"name": "李四", s: false}, {"name": "王五", s: false}];        ve.click=function(){            var arr=[];            for(var i=0;i<vm.c.length;i++){                if(vm.c[i].s){                    arr.push({name:vm.c[i].name})                }            }            vm.l=arr;            vm.lRender()        }    });</script>
相關文章
相關標籤/搜索