0
When accessing pag, titles are color=blue
When you click on the title the color changes to color=red (and opens contents)
But when the title closes it goes back to color=blue
I need: When you click on the title change to the color=red and when you click again when you exit it becomes color=green
I appreciate the help.
JQ321
$(document).ready(function(){
$('#abre').on('click' , function(){ // abre tudo
$('.titulo .conteudo').show();
});
$('#fecha').on('click' , function(){ // fecha tudo
$('.titulo .conteudo').hide();
});
$('.titulo').on('click' , function(){ // abre/fecha cada titulo
var id = $(this).attr('id');
$('#tit'+id).toggle();
var classes = ['red','green']; // Nomes das classes CSS
this.className = classes[($.inArray(this.className, classes)+1)%classes.length]; // Altera a class conforme o clique
});
});
CSS
.titulo {color:blue}
.red {color:red}
.green {color:green}
.conteudo {display: none;}
@media(min-width:800px){
.lista-titulos {
-webkit-column-count: 2;
-moz-column-count: 2;
column-count: 2;
}
.titulo,.mostra{
-webkit-column-break-inside: avoid;
page-break-inside: avoid;
break-inside: avoid;
}
}
@media(min-width:1024px){
.titulo {cursor:pointer}
.titulo:hover {background:yellow}
PHP/HTML5
<div class="lista-titulos">
BD select while...
<div class="titulo" id="<?=$id?>"><span class="tit<?=$id?>"><?=$perg?>/span>
<span id="tit<?=$id?>" class="conteudo">
<div class="mostra">TEXTO</div>
</span>
</div>
</div>
NO RODAPÉ
<div><button type="button" id="abre">abrir tudo</button> <button type="button" id="fecha">fechar tudo</button></div>
Wéllingthon, thanks for the quick response, its function is perfect, but is conflicting with the function opens/closes all titles. (Qdo opens individual and then click open all, gets confused) I did a full function update, css and html. I’m sorry I didn’t inform you correctly. I appreciate your attention and time spent Abs.
– Geo
@Geo see now, what was happening is that clicking on the title changed the value of the attribute Class of
class="titulo"
forclass="red"
hence the jQuery couldn’t find the dial.titulo
.– NoobSaibot
is perfect. NOTE 1000 for your attention and patience. I analyzed the code and learned a little more. A hug and many thanks.
– Geo
I am new here and I saw that my question is -1. Was it very basic, poorly formulated or out of context? Who scores is the Administrator? Just curious rsrs. Abs and thanks again, it was great!!!!
– Geo
Behold Help Center > Asking, you can improve it by formatting, and explaining your problem, etc. Look at this link I passed.
– NoobSaibot