You can add a class to the parent of the red div, e.g. green-style
$('.red').parent().addClass('green-style');
then add style to the css
.green-style .red {
background:green;
}
so everytime you add red element under green-style, the background will be green