2016-08-23 40 views
0

我已經添加了引導行。現在,我想添加複選框,使得複選框應該不像現在一樣逐行顯示。這是HTML。如何將動態創建的複選框添加到引導行

<div class="row" id="ReportRow"> 
     <div class="col-md-12"> 
     </div> 
</div> 

,這裏是jQuery的

var Reports = "User, Admin, Detail, Summary"; 
var arrReportscheckBoxItems = Reports.split(','); 
var reportscheckBoxhtml = '' 
for (var i = 0; i < arrReportscheckBoxItems.length; i++) { 
     reportscheckBoxhtml += '<label style="font-weight: 600; color: #00467f !important;"><input type="checkbox" value=' + arrReportscheckBoxItems[i] + '>' + arrReportscheckBoxItems[i] + '</label><br\>'; 
} 
$('#ReportRow').html(reportscheckBoxhtml); 

Plesae幫我正確對齊。謝謝。

+5

嘗試在你的代碼去除''標籤取下<br/>。 –

回答

1

Fiddle

剛剛從我們的代碼

var Reports = "User, Admin, Detail, Summary"; 
var arrReportscheckBoxItems = Reports.split(','); 
var reportscheckBoxhtml = '' 
for (var i = 0; i < arrReportscheckBoxItems.length; i++) { 
     reportscheckBoxhtml += '<label style="font-weight: 600; color: #00467f !important;"><input type="checkbox" value=' + arrReportscheckBoxItems[i] + '>' + arrReportscheckBoxItems[i] + '</label>&nbsp;'; 
} 
$('#ReportRow > .col-md-12').html(reportscheckBoxhtml);