• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1098
  • Last Modified:

Javascript onmouseover onmouseout onclick


   I need to change the image onmouseover and onmouseout and onclick and when I click the image it has to stay there until I select another image. I am looking for the Javascript program for this logic All this images will be use for the website top navigation
2 Solutions
Pravin AsarPrincipal Systems EngineerCommented:
Instead of changing the mouseover/mouseout function for each image, why not have a function examine
the src and do the action.

For example:
<script language="javascript">
function MyOnFcn(imgObj) {

    if (imgObj.src.match("img1.gif")) {
               alert ('Currently displayed image: ' + imgObj.src);
    else {
               alert ('Other Images: ' + imgObj.src);
function MyOutFcn(imgObj) {
<img src="img1.gif" onclick="this.src='img2.gif';" onmouseover="MyOnFcn(this);" onmouseout="MyOutFcn(this);">

CWS (haripriya)Commented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now