-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptdesc.js
27 lines (22 loc) · 1.05 KB
/
optdesc.js
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
var _optdesc = document.getElementsByClassName('optdesc');
for (var c = 0; c < _optdesc.length; c++) {
var bloco = _optdesc[c];
var d = document.createElement('div');
d.className = 'mostrardescricao';
d.dataset.secao = bloco.dataset.secao;
d.innerHTML = '<div><span class="mais"></span><i class="fa fa-angle-down fa-2x imais" aria-hidden="true"></i></div>';
bloco.children[0].id = bloco.dataset.secao;
d.addEventListener('click', function(e){
var secao = this.dataset.secao;
if(this.children[0].children[0].className == 'menos'){
document.getElementById(secao).className= '';
this.children[0].children[0].className = 'mais';
this.children[0].children[1].className = 'fa fa-angle-down fa-2x imais';
}else{
document.getElementById(secao).className= 'selecionado';
this.children[0].children[0].className = 'menos';
this.children[0].children[1].className = 'fa fa-angle-down fa-2x imenos';
}
});
bloco.appendChild(d);
}