Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Change onmouseout method with onclick

Posted on 2005-03-29
3
Medium Priority
?
569 Views
Last Modified: 2012-06-21
Hey all,

I need to change the onmouseout function of an element when I click on it.  For example, I want it to call one JavaScript function when I mouse out of an image until I click on that image, after which I want to call another function when I mouse out of it.  I thought that I might be able to use the addEventHandler() method, but can't seem to get it to work.  Any ideas?
0
Comment
Question by:jonbigelow
1 Comment
 
LVL 19

Accepted Solution

by:
dakyd earned 500 total points
ID: 13657713
Here's an example, though I think you'll probably want something a bit more complicated than this.  It starts out with a mouseout that turns the div yellow, but once you click on it, the mouseout turns the div red.  Hope that helps, but if you need something more suited to what you want, let us know.

<div onclick="this.onmouseout = function() {this.style.backgroundColor = 'red';};" onmouseover="this.style.backgroundColor = 'green';" onmouseout="this.style.backgroundColor = 'yellow';">TEST DIV</div>
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question