Hi, I'm no great shakes at Javascript... I do all my stuff through Dreamweaver.

My situation is fairly simple. I have image "A" that has its own mouseover and mouseout (to change it back to what it was). BUT I am having difficulties figuring out how to get the mouseOVER image to stay on when the image is clicked.

This is further complicated because the image already has an onClick to change image "B".

I can post the code I have in Dreamweaver as of right now if that would help. I figure I need another onClick to somehow remove the onMouseOut. Or something, ha ha I don't know.

Thanks for any help anyone can give me though! This seems like a really great community... I'm glad I found it!

Recommended Answers

All 5 Replies

FINALLY found the answer after an hour of searching Google. For anyone else that wants to achieve what I was trying to do but doesn't know much of anything about Javascript, I added THIS to my existing onClick for the element that I wanted to stop its mouseout:

this.onmouseover=function(){}; this.onmouseout=function(){}

I don't know what that is, but I think it somehow "clears" previous javascript for that element. It worked!

Or you could do something along the lines of

this.setAttribute("onmouseover", "");
this.setAttribute("onmouseout", "");

> Or you could do something along the lines of
IE has problems with setAttribute. Plus assigning a function reference to an event listener is better than assigning a blank string to it.

Hi, I'm having the same problem, but I need some help on how to get it right. this is my code:

<IMG border="0" onMouseOver=this.src="home2.gif" onMouseOut=this.src="home.gif" onClick=this.src="home2.gif" SRC="home.gif">

Now how do i get the onmouseout not to work when the img is clicked, so it remains as home2.gif?

FINALLY found the answer after an hour of searching Google. For anyone else that wants to achieve what I was trying to do but doesn't know much of anything about Javascript, I added THIS to my existing onClick for the element that I wanted to stop its mouseout:

this.onmouseover=function(){}; this.onmouseout=function(){}

I don't know what that is, but I think it somehow "clears" previous javascript for that element. It worked!

Thats nice - but what to do when you click some other image after this one how do you return its hover functionality?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.