我想從我們的API檢索國家代碼。Bootstrap主題不通過腳本工作
$(document).ready(function() {
$.ajax({
url: "http://api.ourapi",
dataType: "json",
success: function(countries) {
var selectHTML = "";
selectHTML="<select>";
for(i = 0; i < countries.length; i = i + 1) {
country = countries[i];
selectHTML += "<option value=" + country.countryCode + ">" + country.countryName + "(" + country.countryPrefix +")</option>";
}
selectHTML += "</select>";
document.getElementById("countrycode").innerHTML = selectHTML;
}
});
});
<td>
<div class="form-group">
<label class="control-label" for="countrycode"></label>
<div id="countrycode" class="col-sm-6 col-md-12"></div>
</div>
</td>
我得到的結果。但問題是Bootstrap不能在select元素上工作,因爲它以舊的html格式顯示。
我怎樣才能讓它以自舉的方式顯示,以及如何減少選擇元素的寬度?
它的工作......但
您可以發佈完整的HTML代碼?瞭解引導網格的設置將會更容易。 – Danny
完整的html代碼被添加 – mymail