Highlight image when selected/clicked with CSS?


#1

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. :slight_smile:

Thanks.


#2

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');
	});
});

#3
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. :slight_smile:

Thanks.

maybe something like this Click


#4

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? :slight_smile:


#5

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