¿Cómo puedo cambiar el número del elemento tc4? Cuando los dos elementos anteriores tenían una clase oculta.
este mi codigo:
<style> :before{ display:block; margin-top:10px; font: inherit; } .tc-hidden{ display:none; } .tc1 h3.tm-section-label:before { content: "1"; } .tc2 h3.tm-section-label:before { content: "2"; } .tc3 h3.tm-section-label:before { content: "3"; } .tc4 h3.tm-section-label:before { content: "4"; } .tc2.tc-hidden ~ .tc3 h3.tm-section-label:before { content: "2"; font: inherit; } .tc3.tc-hidden ~ .tc4 h3.tm-section-label:before { content: "3"; font: inherit; } .tc2.tc-hidden .tc3.tc-hidden ~ .tc4 h3.tm-section-label:before { content: "2"; font: inherit; } </style> <div class="tc-cell tc1"> <h3 class="tm-section-label"></h3> </div> <div class="tc-cell tc2 tc-hidden"> <h3 class="tm-section-label"></h3> </div> <div class="tc-cell tc3 tc-hidden"> <h3 class="tm-section-label"></h3> </div> <div class="tc-cell tc4"> <h3 class="tm-section-label"></h3> </div>El elemento TC4 debe mostrar el número 2. Pero ahora muestra el número 3.
No importa si este código está hecho con css o jQuery.
Sus selectores están todos en mal estado, algunos no apuntan a ningún elemento en absoluto. con su código puede lograr lo que desea agregando una sola coma.
.tc2.tc-hidden, .tc3.tc-hidden ~ .tc4 h3.tm-section-label:before { content: "2"; font: inherit; }¡Sin embargo, es posible que desee leer más sobre las reglas de CSS y mantenerlo simple también!