I'm a beginner with jquery
and I stumbled upon this piece of code that changes the background of a div
when you hover over it and revert to the original color on mouse out:
(document).ready(function(){
$(".t8").mouseover(function(){
$(".scover8").css("background-color", "rgba(0,24,60,0.60)");
});
$(".t8").mouseout(function(){
$(".scover8").css("background-color", "rgba(0,0,0,0.30)");
});
});
While this is working well for one div
, I need to apply it to 9 different div's
. Instead of repeating the same code block, I would like to use a for loop. I've seen various examples, but I'm struggling to adapt them to my specific case.
Could someone provide assistance with this?
Here is the HTML CODE (repeated 9 times for .t1, .scover1 / .t2, .scover2 etc.):
<div class="t8" onclick="location.href='index.php?page=databank';" style="cursor:pointer;">
<div class="scover8">
<h1><a href="index.php?page=databank">Databank</a></h1><br>
<h2>Download hier beeld & informatie materiaal.</h2><br>
<h3>Omschrijvingen, Product Foto's etc.</h3>
</div>
</div>