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

139
Views
How to add mouseover event listner to show that Im hovering over a particular image?

so I have used a img tag inside a list tag and I want to use a mouse over event to show on which image Im hovering above

<div class="imgBox"><img src="" alt="" /></div>
<ul class="Thumbnail" id="thumbnail">
  <li>
    <a href="img1.jpg" target="imgBox"
      ><img src="img1.jpg" width="120px"
    /></a>
  </li>
  <li>
    <a href="img2.jpg" target="imgBox"
      ><img src="img2.jpg" width="120px"
    /></a>
  </li>
  <li>
    <a href="img3.jpg" target="imgBox"
      ><img src="img3.jpg" width="120px"
    /></a>
  </li>
  <li>
    <a href="img4.jpg" target="imgBox"
      ><img src="img4.jpg" width="120px"
    /></a>
  </li>
  <li>
    <a href="img5.jpg" target="imgBox"
      ><img src="img5.jpg" width="120px"
    /></a>
  </li>
</ul
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You could use onmouseover html native event on your image element like this

<img onmouseover="yourfunction(this)">

doc

about 4 years ago · Juan Pablo Isaza Report

0

It's worth noting the mouseover event bubbles. If you choose to use this you can just set a single mouseover event listener on the parent element (the <ul>) rather than setting event listeners on every image.

You can do this as follows...

document.getElementById("thumbnail").addEventListener("mouseover", outputImage);

function outputImage(e) {
  e.target.style.borderColor = "// desired color";
}

If you are unfamiliar with event bubbling and capturing, please refer to this SO thread.

Edit: Now that you've mentioned your goal is to change the border color, consider the :hover CSS pseudo-class as others have mentioend.

about 4 years ago · Juan Pablo Isaza Report

0

You can add "onmouseover ="function(parameter)" to your HTML img element. With this you can point to a JavaScript function that executes whenever you hover over that element.

This page explains how to do so

about 4 years ago · Juan Pablo Isaza Report
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!