In Joomla I have a web page that, depending on the page, the modules on the right change, each module only has a class that distinguish them, all of them are the same. Since I cannot change this I thought that I could get the text of their heading, trim it and compare it and depending on the outcome add a class so specific css rules would apply, this works fine, but on a module I need to add the class to the .moduletable div not the h3 part how can I do this? here's my code:
$('#right .moduletable h3').each(function(){
var text = $(this).text().trim();
console.log(text);
switch(text){
case 'Ultimos Tips!':
$(this).addClass('conAmor');
break;
case '¿Conoces los códigos QR?':
$(this).addClass('quienesSomos');
break;
case 'Productos':
$(this).addClass('productos');
break;
case 'carouselcavero':
$(this, ':parent').addClass('carromod');
break;
}
});
The last case is the one that I need, it does add the class but it keeps adding it to the h3 not the parent div.
$(this).parent().addClass('carromod');