Example 2

Reuse the dom

JS code

$("img").click(function() {
	$(this).toggleClass("selected");
});
	

HTML code

<img src="http://lorempixel.com/100/100" alt="">
<img src="http://lorempixel.com/100/100" alt="">
		.
		.
		.
<img src="http://lorempixel.com/100/100" alt="">
<img src="http://lorempixel.com/100/100" alt="">
				

CSS code

img {
	opacity: 0.5;
	transition: all 500ms;
	-moz-transition: all 500ms; /* Firefox 4 */
	-webkit-transition: all 500ms; /* Safari and Chrome */
	-o-transition: all 500ms; /* Opera */
}

.selected {
	border: 1px solid green;
	opacity: 1;
}