$(document).ready(function() { //hide all divs with class of report $("div.report-list").hide(); //get all div's that are links with the class of report-region and run the function on each of them (.each is jquery specific) using an array to add +1 each time it runs so matches up the link and list. Index increments each time the loop is run $('a.report-region').each( function(index) { //$(this) equals the current anchor $(this).click(function() { //hide all open divs with class of answer $("div.report-list").hide(); //get the corrsponding div from array referenced by Index and show it $('div.report-list:eq(' + index + ')').show('slow'); return false; }); }); });