框架 也可以这样用 easy

多学习 对你有好处

<div class="a3g w90" style="display: none">
    <h3></h3>
    <span class="rules fl-r js-rules"><a>?</a>排行规则</span>
    <ul class="ul3">
        <script id="a3g" type="text/html">
            <%for(var i=0;i<message.length;i++){%>
                <li>
                    <div class="winfo">
                        <div class="prize <%if(i==0){%>red<%}else if(i==1){%>yellow<%}else{%>green<%}%>"><span><%=i+1%></span></div>
                        <div class="ninfo">
                            <a href=""class="fl-l"><img src="http://f3.v.veimg.cn/company_picture/<%=message[i].company_logo%>" alt="" width="85%" height="85%"></a>
                            <div class="fl-r">
                                <h6><a href=""><%=message[i].company_name%></a></h6>
                                <p><span class="icomoon">&#xe901;</span>热度 <span><%=message[i].micro_station_share_num%></span></p>
                            </div>
                        </div>
                    </div>
                </li>
            <%}%>
        </script>
    </ul>
</div>
$.ajax({
                url:'http://special.veryeast.cn/index.php?m=elite_return&c=index&a=boss',
                type:'get',
                dataType:'jsonp',
                success:function(data){
                    //console.log(data);
                    var html=template("boss",data);
                    $('.boss').html(html);
                    var role=$('.js-boss > li > .wlist > .video > div > img');
                    var arr=[];
                    for(var i=0;i<role.length;i++){
                        arr.push(role.eq(i).data('userid'));
                    }
                    //console.log(arr);
                    for(var i=0;i<role.length;i++){
                        if(role.eq(i).data('userid')==arr[i]){
                            if(role.eq(i).data('role')==1){
                                role.eq(i).attr('src','http://f3.v.veimg.cn/ve/special/201602/elite/melite/images/'+arr[i]+'-1.png');
                            }else if(role.eq(i).data('role')==2){
                                role.eq(i).attr('src','http://f3.v.veimg.cn/ve/special/201602/elite/melite/images/'+arr[i]+'-2.png');
                            }else{
                                role.eq(i).attr('src','http://f3.v.veimg.cn/ve/special/201602/elite/melite/images/'+arr[i]+'-3.png');
                            }
                        }
                    }
                }
            });
    原文作者:fuohua
    原文地址: https://segmentfault.com/a/1190000004631651
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞