template.js

需要引用js文件

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

设置模板

<div id="facelist">div>


        <script type="text/html" id="facetemplate">
            
"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;">
in" role="tooltip" style="top: {{top}}px; left: {{left+width}}px; display: block;">
">
颜值:">{{score}}</span>
> 年龄:<span id="agetext">
{{age}}</span>
> 性别:<span id="agetext">
{{sex}}</span>
> 评价:<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=0


initParams.age=1
initParams.sex=1;
initParams.desc='123123'
initParams.score='3333' 
facelist.append(template("facetemplate",initParams));
$("#faces").show(); 

你可能感兴趣的:(JavaScript)