/    Sign up×
Community /Pin to ProfileBookmark

onMouseOut and onClick

Hi,

I have 3 different versions of an image and I am modifying the image with onMouseOver, onMouseOut and onClick events.

The problem is the image after onClick event is being overwritten by the onMouseOut event. How do I void the onMouseOut event after onClick event ?

default image: image1
onMouseOver: image2
onMouseOut: image1
onClick: image3

In essence, I want to retain ‘image3’ after onClick event (moving the mouse should not trigger onMouseOut).

Is it possible ?

Thanks
vmrao

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@CrazyMerlinJun 01.2007 — on way would be to have a flag variable called 'clicked' which is set to true inside onclick.

in your onmouseout method see if 'clicked' is set to true and it so, set it back to false then 'return false'

make sure the 'clicked' flag is declared outside all functions to give it global scope.

//erlin!
×

Success!

Help @vayumahesh spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...