Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

166
Vistas
check the total of class of this container then set a condition

I'm new to jquery I would like to ask, how I can declare a condition, by checking the total of a class of the container. because I have several of these classnames but it will be removed based on my set condition, so i am wondering if I have this total of classes on this container, then the style of my container will be changed like this.

if this div.container class has a total of 3 classes of .className then set a .attr('style', 'max-width: 400px !important').

<div class="container">
<div class="className">
<div class="className">
<div class="className">

is this possible? or anyways to have this achievable? please enlighten me. Thank you

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try this,

<script>
$(document).ready(function(){
var count = $('.container .className').length;
if(count==3){
$('.container').attr('style', 'max-width: 500px !important');

}
 
});
</script>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda