根据样式往里添加动态数据

<div id="lefttrainingPlan">
    <div id="trainingPlantitle">训练计划<span class="titleright"><img src="css/common/image/titleright.png" /></span></div>
    <div id="trainingPlanbody">
        <div id="trainingPlanleft">
<%--       <ul class="ul">
                <li class="litime">2015/11/19<br />
                    08:00</li>
                <li class="litime">2015/11/19<br />
                    10:30</li>
                <li class="litime">2015/11/19<br />
                    14:00</li>
                <li class="litime">2015/11/19<br />
                    18:30</li>
            </ul>--%>
        </div>
        <div id="trainingPlancenter">
            <img src="css/common/image/planonefour.png" />
        </div>
        <div id="trainingPlanright">
   <%--         <ul class="ul">
                <li class="libody">活动身体</li>
                <li class="libody">活动身体</li>
                <li class="libody">活动身体</li>
                <li class="libody">活动身体</li>
            </ul>--%>
        </div>

            <script type="text/javascript">
                $(function () {
                    GetTodayPlanFromWeekPlanTable();
                });
                function GetTodayPlanFromWeekPlanTable() {
                    $.post(location.href, { "action": "weekPlansInfo" }, function (data) {        //向后太代码传值
                        if (data != "0") {
                            var dataObj = eval("(" + data + ")");
                            var newstr = '<ul class="ul">';                                          //在原来的样式中找到添加      
                            var newstrd = '<ul class="ul">'                                          //如上         
                            for (var i = 0; i < 4; i++) {                                             //循环添加
                                newstr += '<li class="litime">' + dataObj.rows[i].JSON_datenow   + '<br />' + dataObj.rows[i].JSON_starttime + '</li>';          //拼接<li></li>alter()找到所需的JSON_。。所需要的数据
                                newstrd += '<li class="libody">' + '<a href="' + dataObj.rows[i].JSON_weeksplansid + '">' + dataObj.rows[i].JSON_weektask + '</li>'
                            }
                            newstr += '</ul>';
                            newstrd += '</ul>';
                            $("#trainingPlanleft").append(newstr);
                            $("#trainingPlanright").append(newstrd);
                        }
                    });
                }
    </script>
    </div>
</di

posted @ 2015-11-21 14:11  怎能不累  阅读(214)  评论(0编辑  收藏  举报