Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!