I am attempting to adjust the height
of a parent div
based on the length of text in its child p.descr
. This is achieved by adding a specific class
that corresponds to different height
values in CSS. Below is the jQuery code snippet:
$(document).ready(function(){
$('p.descr').each(function(){
if($(this).text().length < 90){
$(this).parent().addClass('bigP90');
} if($(this).text().length [90,180]) {
$(this).parent().addClass('bigP180');
} if($(this).text().length [181,270]) {
$(this).parent().addClass('bigP270');
} if($(this).text().length [271,360]) {
$(this).parent().addClass('bigP360');
} if($(this).text().length > 360) {
$(this).parent().addClass('bigP450');
}
});
});
The issue I'm facing is that the classes bigP90
and bigP450
are getting applied correctly, but not those in between. It seems like there might be a syntax error, but I haven't been able to identify it yet. Any help would be appreciated. Thank you.