1
我想用jQuery 2.1.4創建一些Bootstrap 3.3.5選項卡,但我並沒有太多。我只能看到標題標題,而不是實際的內容。我已經制作了一個JSFiddle的相關代碼。以編程方式創建Bootstrap選項卡
<header class="navbar navbar-static-top">
<div class="container">
<nav>
<ul class="nav nav-tabs" id="navigtion"></ul>
</nav>
</div>
</header>
<div class="container-fluid">
<div class="tab-content" id="tabulator"></div>
</div>
var categories = {
general: {
label: "General",
options: [{
key: "opt1",
label: "Option 1",
desc: "The first option",
def: true
}, {
key: "opt2",
label: "Option 2",
desc: "The second option",
def: true
}]
},
advanced: {
label: "Advanced",
options: [{
key: "opt3",
label: "Option 3",
desc: "The third option",
def: false
}]
}
};
$(function() {
$.each(categories, function (i, v) {
$("#navigtion").append("<li><a data-toggle='tab' data-target='" + i + "'>" + this.label + "</a></li>");
$("#tabulator").append("<div class='tab-pane' id='" + i + "'/>");
$.each(this.options, function (i2, v2) {
$("#" + i).append("<div class='checkbox'><label><input type='checkbox' id='" + this.key + "' title='" + this.desc + "'>" + this.label + "</label></div>");
});
});
});
我得到一個「常規」和「高級」選項卡。期望的結果是什麼? –
對不起,我會更新OP。每個選項卡中也有實際的內容,但只是沒有激活。 –
嘗試用以下代替:$(「#navigation」)。append(「