Displaying image for the selected year
Create a style for the classes hidden_year and visible_year. When you click a link use a selector that selects all with id containing "year_19" and set them all to hidden_year, then just set the link you clicked to visible_year.

You could use a loop to build up the id values 5-9 if you really wanted to. . . var curr_year = 'year_19' + i + '0' in a loop.

Here is an example:

&lt;!doctype html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset="utf-8"&gt;
&lt;title&gt;Year test&lt;/title&gt;

&lt;style&gt;
.hidden_year {
    transition: left 0.5s linear 0s;
    position:absolute;
    top:0px;
    left:-500px;

}

.visible_year {
    transition: left 0.5s linear 0s;
    position:absolute;
    top:0px;
    left:50px;
}

&lt;/style&gt;
&lt;script&gt;

function process(id) {
$('[id*="year_19"]').each(function(index) {
        $(this).removeClass().addClass('hidden_year');
    });
$('[id=' + id + ']').removeClass().addClass('visible_year');
}


&lt;/script&gt;

&lt;/head&gt;

&lt;body&gt;

&lt;div id="year_1950" class="hidden_year"&gt;&lt;img src="http://dtwdev.co.uk/new/bg_1950.jpg"&gt;&lt;/div&gt;
&lt;div id="year_1960" class="hidden_year"&gt;&lt;img src="http://dtwdev.co.uk/new/bg_1960.jpg"&gt;&lt;/div&gt;
&lt;div id="year_1970" class="hidden_year"&gt;&lt;img src="http://dtwdev.co.uk/new/bg_1970.jpg"&gt;&lt;/div&gt;
&lt;div id="year_1980" class="hidden_year"&gt;&lt;img src="http://dtwdev.co.uk/new/bg_1980.jpg"&gt;&lt;/div&gt;
&lt;div id="year_1990" class="hidden_year"&gt;&lt;img src="http://dtwdev.co.uk/new/bg_1990.jpg"&gt;&lt;/div&gt;


&lt;div&gt;&lt;a href="javascript:void(0);" onclick="process('year_1950')"&gt;1950&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;&lt;a href="javascript:void(0);" onclick="process('year_1960')"&gt;1960&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;&lt;a href="javascript:void(0);" onclick="process('year_1970')"&gt;1970&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;&lt;a href="javascript:void(0);" onclick="process('year_1980')"&gt;1980&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;&lt;a href="javascript:void(0);" onclick="process('year_1990')"&gt;1990&lt;/a&gt;&lt;/div&gt;





&lt;script src="http://dtwdev.co.uk/new//js/jquery.min.js"&gt;&lt;/script&gt;   
&lt;script src='http://dtwdev.co.uk/new//js/css3-animate-it.js'&gt;&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;