2016-11-30 12 views
1

如何在for循环中显示的每个项目之间放置换行符。如何使用jquery append时放置断行

for (var t = 0; t < userList.length; ++t) { 

       var href = 'http://localhost:53008/authenticationcleaner/userprofile?id=' + userList[t].Id; 
       var text = 'The ' + userList[t].LastName + ' Family, ' + 'Address: ' + userList[t].Address; 
       $('.families').append($('<a/>').attr('href', href).text(text)); 
      } 

回答

2

for (var t = 0; t < 5; ++t) { 
 

 
       var href = 'http://localhost:53008/authenticationcleaner/userprofile?id=' + t; 
 
       var text = 'The ' + t + ' Family, ' + 'Address: ' + t; 
 
       $('.families').append($('<a/>').attr('href', href).text(text)).append('<br/>'); 
 
       
 
      }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div class="families"> 
 

 
</div>

+0

太感谢你了! – Newbie

相关问题