使用JS动态向div中append内容

html代码

  

1 <div class="easyui-layout" data-options="fit:true,plain:true">
2         <div id="topStationList" nowrap data-options="region:'north',split:true" style="padding: 0px; height: 16%;padding-top: 10px; padding-left: 20px;">
3             <!-- <a href="#" class="easyui-linkbutton" style="width:10%" data-options="iconCls:'icon-large-smartart',size:'large',iconAlign:'top'">上海站</a> -->
4         </div>
5 </div>

 

JS代码

  

 1 $(document).ready(function()
 2     {
 3         currDraftName = ${param.draftName};
 4         $.getJSON("param-common/getStationList.action?_dc=" + Math.random(), function(jsonData)
 5         {
 6             var stationHtml = "<nobr>";
 7             $.each(jsonData, function(stationId,stationName)
 8             {
 9                 stationHtml = stationHtml + '\
10                 <a name="stationBtn" id="'+stationId+'"class="easyui-linkbutton"  plain="true" href="javascript:doStationParam(\''+stationId.toS     tring()+'\');" style="width:100px" data-options="iconCls:\'icon-large-smartart\',size:\'large\',iconAlign:\'top\',toggle:true,selected:false">     '+stationName+'</a>\
11                 ';
12             });
13             var stationHtml = stationHtml+"</nobr>";
14             var div = $('#topStationList');
15             div.append(stationHtml);
16             //console.log(stationHtml);
17             $.parser.parse(div);
18         });
19     });

 

效果图

 

posted @ 2017-07-31 15:49  像艳遇一样忧伤c  阅读(5125)  评论(0编辑  收藏  举报