-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnetflixclonejs.js
More file actions
44 lines (30 loc) · 1.25 KB
/
netflixclonejs.js
File metadata and controls
44 lines (30 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
console.log("hi javascript");
const tabItems=document.querySelectorAll(".tab-item");
const tab1content=document.querySelector('#tab-1-content');
const tab2content=document.querySelector('#tab-2-content');
const tab3content=document.querySelector('#tab-3-content');
function removeBorder(){
tabItems.forEach(item =>item.classList.remove('tab-border'));
}
//listen for tab click
tabItems.forEach(item => item.addEventListener('click',function(){
removeBorder();
//add border to current tab
item.classList.add('tab-border');
//grab content item from DOM
const tabContentItem=document.querySelector(`#${this.id}-content`);
tabContentItem.classList.add('showtabcontent');
//show the current tab data and hide rest tabs data
if(tabContentItem==tab1content){
tab2content.classList.remove('showtabcontent');
tab3content.classList.remove('showtabcontent');
}
else if(tabContentItem==tab2content){
tab1content.classList.remove('showtabcontent');
tab3content.classList.remove('showtabcontent');
}
else{
tab1content.classList.remove('showtabcontent');
tab2content.classList.remove('showtabcontent');
}
}));