$(document).ready(function() { $('#works a').lightBox(); $('.work>a>img').fadeTo("fast",1); //start the engine $('.work>a>img').hover(function() { section = $(this).attr('name'); $('#' + section + '>img').fadeTo("fast",1); }, function () { $('#' + section + '>img').fadeTo("fast",1); }); });