Skip to content

Commit d260ef5

Browse files
committed
17 video
1 parent 6a9c9d2 commit d260ef5

3 files changed

Lines changed: 44 additions & 8 deletions

File tree

‎app.js‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,20 @@ searchBar.addEventListener('keyup', function(e){
5757
book.style.display = 'none';
5858
}
5959
});
60-
});
60+
});
61+
62+
//tabbed content
63+
const tabs = document.querySelector('.tabs')
64+
const panel = document.querySelectorAll('.panel');
65+
tabs.addEventListener('click', function(e){
66+
if(e.target.tagname == 'LI'){
67+
const targetPanel = document.querySelector(e.target.dataset.target);
68+
panel.forEach(function(panel){
69+
if (panel == targetpanel){
70+
panel.classList.add('active');
71+
} else {
72+
panel.classList.remove('active');
73+
}
74+
})
75+
}
76+
})

‎index.html‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,26 @@ <h2 class="title">Books to Read</h2>
3838
</ul>
3939
</div>
4040
<form id="add-book">
41-
<input type='checkbox' id='hide'/>
42-
<label for='hide'>Hide all books</label>
41+
<input type="checkbox" id="hide" />
42+
<label for="hide">Hide all books</label>
4343
<input type="text" placeholder="Add a book..." />
4444
<button>Add</button>
4545
</form>
46-
46+
<div id="tabbed-content">
47+
<ul class="tabs">
48+
<li data-target="#about" class="active">About</li>
49+
<li data-target="#contact">Contact</li>
50+
</ul>
51+
<div class="panel active" id="about">
52+
<p>Content for about tab...</p>
53+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum id nunc porta urna ornare rhoncus. Ut convallis ante at.</p>
54+
</div>
55+
<div class="panel" id="contact">
56+
<p>Content for contact tab...</p>
57+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum id nunc porta urna ornare rhoncus. Ut convallis ante at.</p>
58+
</div>
59+
</div>
4760
</div>
4861
<script src="app.js"></script>
4962
</body>
50-
</html>
63+
</html>

‎styles.css‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,16 @@ h1, h2{
123123
line-height: 52px;
124124
}
125125

126-
/*
127-
#tabbed-content .tab{
126+
#tabbed-content li{
127+
display: inline-block;
128+
padding: 10px 14px;
129+
background: #ddd;
130+
border-radius: 4px;
131+
cursor: pointer;
132+
margin-right: 10px;
133+
}
134+
135+
#tabbed-content .panel{
128136
display: none;
129137
border: 1px solid #ddd;
130138
padding: 0 10px;
@@ -134,4 +142,3 @@ h1, h2{
134142
#tabbed-content .tab.active{
135143
display: block;
136144
}
137-
*/

0 commit comments

Comments
 (0)