xxxxxxxxxx
1
<div class='container'>
2
3
4
<div class="text-white" id='gdpr_adjust' style='background-color: #000000; width:300px; height:200px; margin:10px auto'> <p>
5
This is the div to hide1
6
</p>
7
</div>
8
9
<div id='gdpr_basic' style='background-color: #eeeeee; width:300px; height:200px; margin:10px auto'> <p>
10
This is the div to hide2
11
</p>
12
</div>
13
<button id='displayNoneBtn' class='btn btn-primary'>
14
Display None
15
</button>
16
17
18
</div>
xxxxxxxxxx
1
.container {
2
width:100%;
3
display:flex;
4
flex-direction:column;
5
}
6
#divToHide {
7
position:relative;
8
display: flex;
9
justify-content:center;
10
align-items:center;
11
}
12
13
#displayNoneBtn{
14
position:absolute;
15
top: 40%;
16
left:10%;
17
}
18
19
xxxxxxxxxx
1
const displayBtn = document.getElementById('displayNoneBtn');
2
const gdpr_adjust = document.getElementById('gdpr_adjust');
3
const gdpr_basic = document.getElementById('gdpr_basic');
4
5
// define functions
6
function setDisplayNone () {
7
gdpr_adjust.style.display = 'none';
8
gdpr_basic.style.display = 'none';
9
10
};
11
12
// add listeners to connect functions with buttons
13
displayBtn.addEventListener('click', setDisplayNone);
14
Console errors: 0