Is it possible to dynamically change the style of paragraphs based on certain classes? Let's say we have a text with a list of p elements and we want to modify the styles of paragraphs that come after specific classes, such as 'alert' or 'danger'. The order is important here - alerts come first followed by dangers. However, both are optional and can be preceded by other paragraphs that don't fall into those categories.
<div class='text'>
<p>Some paragraph0</p>
<p class="alert">Alert</p>
<p>Some paragraph1</p>
<p>Some paragraph2</p>
<p class="danger">Danger</p>
<p>Some paragraph3</p>
<p>Some paragraph4</p>
</div>
The main issue is figuring out how to apply style changes to elements that come after paragraphs with either the alert or danger class. Ideally, we should be able to specify whether these changes should be applied before or after the designated paragraphs.
.alert{
background: #FFFF00;
font-weight: bold;
}
.danger{
background: #F00;
font-weight: bold;
}