HTML
xxxxxxxxxx
1
<div class="row">
2
<div class="col-4">
3
<div class="list-group list-group-light tablist" id="list-tab" role="tablist">
4
<a class="list-group-item list-group-item-action active px-3 border-0" id="list-home-list"
5
data-mdb-list-init href="#list-home" role="tab" aria-controls="list-home">Home</a>
6
<a class="list-group-item list-group-item-action px-3 border-0" id="list-profile-list"
7
data-mdb-list-init href="#list-profile" role="tab" aria-controls="list-profile">Profile</a>
8
<a class="list-group-item list-group-item-action px-3 border-0" id="list-messages-list"
9
data-mdb-list-init href="#list-messages" role="tab" aria-controls="list-messages">Messages</a>
10
<a class="list-group-item list-group-item-action px-3 border-0" id="list-settings-list"
11
data-mdb-list-init href="#list-settings" role="tab" aria-controls="list-settings">Settings</a>
12
</div>
13
</div>
14
<div class="col-8">
15
<div class="tab-content" id="nav-tabContent">
16
<div class="tab-pane show active" id="list-home" role="tabpanel"
17
aria-labelledby="list-home-list">
18
Some placeholder content in a paragraph relating to "Home". And some more content, used here just to
19
pad out and fill this tab panel. In production, you would obviously have more real content here. And
20
not just text. It could be anything, really. Text, images, forms.
21
</div>
22
<div class="tab-pane" id="list-profile" role="tabpanel" aria-labelledby="list-profile-list">
23
Some placeholder content in a paragraph relating to "Profile". And some more content, used here just
24
to pad out and fill this tab panel. In production, you would obviously have more real content here.
25
And not just text. It could be anything, really. Text, images, forms.
26
</div>
27
<div class="tab-pane" id="list-messages" role="tabpanel" aria-labelledby="list-messages-list">
28
Some placeholder content in a paragraph relating to "Messages". And some more content, used here
29
just to pad out and fill this tab panel. In production, you would obviously have more real content
30
here. And not just text. It could be anything, really. Text, images, forms.
31
</div>
32
<div class="tab-pane" id="list-settings" role="tabpanel" aria-labelledby="list-settings-list">
33
Some placeholder content in a paragraph relating to "Settings". And some more content, used here
34
just to pad out and fill this tab panel. In production, you would obviously have more real content
35
here. And not just text. It could be anything, really. Text, images, forms.
36
</div>
37
</div>
38
</div>
39
</div>
CSS
1
1
JS
xxxxxxxxxx
1
const triggerTabList = [].slice.call(document.querySelectorAll('div.tablist'));
2
triggerTabList.forEach((triggerEl) => {
3
const tabTrigger = new mdb.Tab(triggerEl);
4
5
triggerEl.addEventListener('click', (event) => {
6
event.preventDefault();
7
tabTrigger.show();
8
});
9
});
Console errors: 0