Skip to content

Instantly share code, notes, and snippets.

@rafaelstz
Last active August 29, 2015 14:07
Show Gist options
  • Save rafaelstz/9395e90aa1bce95b4d5b to your computer and use it in GitHub Desktop.
Save rafaelstz/9395e90aa1bce95b4d5b to your computer and use it in GitHub Desktop.
Procura texto em uma classe e adiciona a classe.
if ( jQuery('.product-desc').length > 0 ) {
jQuery(function(){
jQuery('.product-desc').each(function(){
if ( jQuery(this).find(".prod-desc-tipo:contains('Grãos')").length > 0 ) {
jQuery(this).find('.icon').addClass('icon1');
}
else if ( jQuery(this).find(".prod-desc-tipo:contains('Cápsula')").length > 0 ) {
jQuery(this).find('.icon').addClass('icon2');
}
else if ( jQuery(this).find(".prod-desc-tipo:contains('Moído')").length > 0 ) {
jQuery(this).find('.icon').addClass('icon3');
}
else if ( jQuery(this).find(".prod-desc-tipo:contains('Sachê')").length > 0 ) {
jQuery(this).find('.icon').addClass('icon4');
}
else { }
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment