Help needed to complete this code. The task is to count the number of .resp-containers in each container separately. Then, based on that count, assign a corresponding class to each element within the containers. Check out the code here
$(document).ready(function(){
var getLength = $(".resp-container").length
var item = $(".resp-container");
switch (getLength) {
case 1: item.addClass("full-resp");
break;
case 2: item.addClass("half-resp");
break;
case 3: item.addClass("third-resp");
break;
case 4: item.addClass("fourth-resp");
break;
default: item.addClass("fourth-resp");
}
});
HTML
<div class="container">
<div class="resp-container"></div>
<div class="resp-container"></div>
<div class="resp-container"></div>
<div class="resp-container"></div>
</div>
<div class="container">
<div class="resp-container"></div>
<div class="resp-container"></div>
<div class="resp-container"></div>
</div>
<div class="container">
<div class="resp-container"></div>
<div class="resp-container"></div>
</div>
<div class="container">
<div class="resp-container"></div>
</div>