How to dynamically add an active state with jQuery to a gallery thumbnail?

You're currently doing this to get the selected image: $('. Selected img#myImage'). Attr('src', 'path_to_active_state.

Jpg') Try doing this to get the unselected image: $(':not(.selected) img#myImage'). Attr('src', 'path_to_active_state. Jpg').

You're currently doing this to get the selected image: $('. Selected img#myImage'). Attr('src', 'path_to_active_state.

Jpg'); Try doing this to get the unselected image: $(':not(.selected) img#myImage'). Attr('src', 'path_to_active_state. Jpg').

You could add a class to the active image, so that you can identify it later.. so $('. Selected img#myImage'). Attr('src', 'path_to_active_state.

Jpg'). AddClass('altered'); and when highlighting another thumbnail $('. Altered').

Attr('src', 'path_to_inactive_state. Jpg'). RemoveClass('altered'); also in your example $('.

Selected img#myImage') seems to imply that you use the same id for all thumbnails (#myImage). Id's should be unique inside the DOM..

Yea, I assigned unique IDs to all of the images so I could target them differently. I was hoping to write something that would get the original source, store it in a variable, assign the new source of the active image and then return it to the original source when another thumbnail was selected. Thanks for your response.

– Patrick Jun 30 '10 at 0:48 @Patrick, you need to create a logic behind the active/non-active paths to the thumbnails.. so that you can make them active/non-active without knowing the original or altered state..(for example a some-image. Jpg for the normal and some-image-active. Jpg for the active, and manipulate the src to add/remove this suffix).

In my code I show you how to add a class to the active one so you can find it later and return it to the non-active image.. – Gaby aka G. Petrioli Jun 30 '10 at 9:22.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions