template.js

来源:互联网 发布:mac修改mysql配置文件 编辑:程序博客网 时间:2024/06/18 12:56

需要引用js文件

<script type="text/javascript" src="js/template.js"></script>

设置模板

<div id="facelist"></div>
        <script type="text/html" id="facetemplate">            <div id="faces" hidden="">                <div data-html="true" class="face-tooltip big-face-tooltip " id="rect3284" style="left: {{left}}px; top: {{top}}px; width: {{width}}px; height: {{height}}px; border: 1px solid white; position: absolute;">                </div>                <div class="tooltip fade top in" role="tooltip" style="top: {{top}}px; left: {{left+width}}px; display: block;">                    <div class="tooltip-inner">                        <div>                            颜值:<span id="scoretext">{{score}}</span><br/>                            年龄:<span id="agetext">{{age}}</span><br/>                            性别:<span id="agetext">{{sex}}</span><br/>                            评价:<span id="desctext">{{desc}}</span>                        </div>                    </div>                </div>            </div>        </script>

给模板设置数据

var facelist=$("#facelist").empty();initParams.left=10; initParams.top=10                       initParams.width=0                          initParams.height=0initParams.age=1initParams.sex=1;initParams.desc='123123'initParams.score='3333' facelist.append(template("facetemplate",initParams));$("#faces").show(); 
原创粉丝点击