Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

78
Views
Change Image src with fade effect on list menu hover

I'm trying to create an effect where you hover over a link and the image in the backgound changes depending on which link was hovered.

function changeImage(artistCover){
document.getElementById('slider').src = artistCover;
}
a {
color:#ffffff;
}
a:hover {
color: orange;
}
.imgArea {
height:100vh; display:flex; justify-content:center; align-items:center;
}
.imgArea img {
 position: absolute;
 z-index: -1;
 top: 0;
 left: 0;
 width: 100%;
 height: 100%;
 object-fit: cover;
}

.imgArea:before {
content:"";
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.4);
z-index:0;
}

ul li {
list-style-type: none; font-size: 24px;line-height: 2em;
font-variant: small-caps;font-weight: bold; text-align:center;
}
<div class="imgArea">
<img src="destinyschild.jpeg" id="slider">
<div style="position:absolute;">
<ul>
<li>
<a href="#" onmouseenter="changeImage('https://weareaddition.com/wp-content/uploads/2022/05/destinyschild.jpeg')">Destiny’s Child</a>
</li>
<li>
<a href="#" onmouseenter="changeImage('https://weareaddition.com/wp-content/uploads/2022/05/littlemix.jpeg')">Little Mix</a>
</li>
<li>
<a href="" onmouseenter="changeImage('https://weareaddition.com/wp-content/uploads/2022/05/Pele.jpeg')">Pele</a>
</li>
<li>
<a href="#" onmouseenter="changeImage('https://weareaddition.com/wp-content/uploads/2022/05/chrisbrown.webp')">Chris Brown</a>
</li>
</ul>
</div>
</div>

The above code works and replaces the image without a fade effect. What do I need to add/modify to get the crosfade effect to work?

Here's a JSFiddle example of my script as well. Many thanks in advance!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!