使用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     });

 

效果圖

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM