382 posts
  • Weekly Top Seller
  • Elite Author
  • Author Level 8
  • New Zealand
+6 more
PixelStores
says

Hey,

I have a list in HTML and some CSS that displays images, the images use one image and simply changes the background position for the hover state.

I want to know if when a user clicks one of the list items the hover state would be set to selected.

I know in form fields you can set the focus, can this be done with a list of links that are images with HTML and CSS .

Perhaps some jquery is involved, some direction would be grateful. :)

Thanks.

1012 posts
  • 5 Years of Membership
  • Affiliate Level 2
  • Author Level 5
  • Collector Level 2
+8 more
wizylabs
says

Hi Matt,

I don’t really understand what you exactly want but I wrote a simple script that adds a ‘selected’ class to the list item when you click on it and remove it from others that had it before.

$('ul li').each(function(){
    $(this).click(function(){
        $('ul li').removeClass('selected');
        $(this).addClass('selected');
    });
});
3439 posts
  • Author Level 4
  • Collector Level 2
  • Community Superstar
  • United States
+2 more
organicbee
says
Hey,

I have a list in HTML and some CSS that displays images, the images use one image and simply changes the background position for the hover state.

I want to know if when a user clicks one of the list items the hover state would be set to selected.

I know in form fields you can set the focus, can this be done with a list of links that are images with HTML and CSS .

Perhaps some jquery is involved, some direction would be grateful. :)

Thanks.

maybe something like this Click

382 posts
  • Weekly Top Seller
  • Elite Author
  • Author Level 8
  • New Zealand
+6 more
PixelStores
says

Yep, sorry guys a bit hard to explain.

I’m using this code, the one with the hover state:

http://www.noobcube.com/wp-content/uploads/demos/073109-cssimagemaps/demo/

What i’m trying to accomplish is when a user clicks on the certain part of the map, the continent stays highlighted.

Any ideas? :)

3007 posts
  • 5 Years of Membership
  • Affiliate Level 5
  • Author Level 9
  • Bundle Boss
+8 more
duotive
says

only javascript…. no css solution exists in my mind…. onclick set class active…

by
by
by
by
by
by