In this example when a paragraph is hovered over its color is changed to blue, I would like all sibling paragraphs to also have this rule applied. Is there a way I can achieve this CSS?
I have the desired functionality working in JavaScript with jQuery, but would like a pure CSS solution.
Edit: It wasn't clear in my original post, this should apply to only select elements. See the updated HTML.
$(".groupHover").hover(
function() {
$(".groupHover").addClass("hoverClass");
},
function() {
$(".groupHover").removeClass("hoverClass");
}
);
.hoverClass {
color: red;
}
.groupHover:hover {
color: blue !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<p class=>Not to be changed!</p>
<p class="groupHover">Line 1</p>
<p class="groupHover">Line 2</p>
<p class=>Not to be changed!</p>
<p class="groupHover">Line 3</p>
<p class="groupHover">Line 4</p>
<p class=>Not to be changed!</p>