Начинающий-Js-кодер,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
div.act{
background-color: #FFD700;
}
div.act div{
background-color: #FFFFFF;
}
div{
margin: 20px;
border: 2px black solid;
}
.act.act1 {
background-color: #FF1493;
}
.act.act2 {
background-color: #FF4500;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(function() {
$("div").on("mouseover mouseout", function(event) {
event.stopPropagation();
var cls = "act";
if($(this).is(".cl1")) cls += " act1";
if($(this).is(".cl2")) cls += " act2";
$(this).toggleClass(cls)
})
});
</script>
</head>
<body>
<div>
<div>
<div>
<div>
<div class="cl1">
<div></div>
</div>
<div class="cl2">
<div></div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>