[Javascript] Maintaining state

tedd tedd at sperling.com
Sat Oct 6 18:14:47 CDT 2007


At 1:29 PM -0400 10/6/07, Roger Roelofs wrote:
>tedd wrote:
>>  Let's say there are three images on a web page such that when the
>>  user moves his/her cursor over one image, a border appears. No
>>  problem, I can do that with css.
>>
>>  However, I would like the border to remain (i.e., maintain state)
>>  after the user has moved the cursor off the image and stay that way
>>  until another image is subject to a rollover -- and then, that image
>>  would maintain state. Only one image maintains state.
>>
>Then you can't use a css hover pseudo-class.  Your best bet is to set
>the class attribute on mouseover and remove the class from the others of
>the group at that time.
>
>If you post the code you are currently using (or better yet, a url to a

Roger:

Yes, I came to the conclusion that I can't use css hover pseudo-class as well.

What I've done below is a bit code verbose and I think there has to 
be a simpler way.

See here:

http://www.webbytedd.com/c/js-maintain-state/

The point here is to simply record a user's selection and maintain it 
like a radio button. I know, I could have used a radio button (in 
fact did), but I wanted to use images instead of radio buttons.

Any ways to get this simpler?

Thanks again to all.

Cheers,

tedd

-- 
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com



More information about the Javascript mailing list