This code works fine but is way to bulky for my liking. Is there a better way to go about filtering classes and adding a style to them?
$('.leftNav li a').click(function() {
$('.leftNav li a').removeClass('active');
$(this).addClass('active');
$('span.overlay').css('opacity','0');
$('ul.thumbnails li').filter('.integrated'), $(function(){ //filter by class
$('.integrated span.overlay').css('opacity', '0.9'); //fade overlay to 1
});
return false; //stops link being followed
});
$('.leftNav li a.integrated').click(function(){
$('.leftNav li a').removeClass('active'); //remove all active classes
$(this).addClass('active'); //add class active
$('span.overlay').css('opacity','0'); //hide all active overlays
$('ul.thumbnails li').filter('.integrated'), $(function(){ //filter by class
$('.integrated span.overlay').css('opacity', '0.9'); //fade overlay to 1
});
return false; //stops link being followed
});
$(".leftNav li a.tv").click(function(){
$('.leftNav li a').removeClass('active'); //remove all active classes
$(this).addClass('active'); //add class active
$('span.overlay').css('opacity','0'); //hide all active overlays
$('ul.thumbnails li').filter('.tv'), $(function(){ //filter by class
$('.tv span.overlay').css('opacity', '0.9'); //fade overlay to 1
});
return false; //stops link being followed
});
$(".leftNav li a.print").click(function(){
$('.leftNav li a').removeClass('active');//remove all active classes
$(this).addClass('active'); //add class active
$('span.overlay').css('opacity','0'); //hide all active overlays
$('ul.thumbnails li').filter('.print'), $(function(){ //filter by class
$('.print span.overlay').css('opacity', '0.9'); //fade overlay to 1
});
return false; //stops link being followed
});
$(".leftNav li a.digital").click(function(){
$('.leftNav li a').removeClass('active');//remove all active classes
$(this).addClass('active'); //add class active
$('span.overlay').css('opacity','0'); //hide all active overlays
$('ul.thumbnails li').filter('.digital'), $(function(){ //filter by class
$('.digital span.overlay').css('opacity', '0.9'); //fade overlay to 1
});
return false; //stops link being followed
});
$(".leftNav li a.dm").click(function(){
$('.leftNav li a').removeClass('active');//remove all active classes
$(this).addClass('active'); //add class active
$('span.overlay').css('opacity','0'); //hide all active overlays
$('ul.thumbnails li').filter('.dm'), $(function(){ //filter by class
$('.dm span.overlay').css('opacity', '0.9'); //fade overlay to 1
});
return false; //stops link being followed
});
$(".leftNav li a.events").click(function(){
$('.leftNav li a').removeClass('active');//remove all active classes
$(this).addClass('active'); //add class active
$('span.overlay').css('opacity','0'); //hide all active overlays
$('ul.thumbnails li').filter('.events'), $(function(){ //filter by class
$('.events span.overlay').css('opacity', '0.9'); //fade overlay to 1
});
return false; //stops link being followed
});
$(".leftNav li a.social").click(function(){
$('.leftNav li a').removeClass('active');//remove all active classes
$(this).addClass('active'); //add class active
$('span.overlay').css('opacity','0'); //hide all active overlays
$('ul.thumbnails li').filter('.social'), $(function(){ //filter by class
$('.social span.overlay').css('opacity', '0.9'); //fade overlay to 1
});
return false; //stops link being followed
});
$(".leftNav li a.branding").click(function(){
$('.leftNav li a').removeClass('active');//remove all active classes
$(this).addClass('active'); //add class active
$('span.overlay').css('opacity','0'); //hide all active overlays
$('ul.thumbnails li').filter('.branding'), $(function(){ //filter by class
$('.branding span.overlay').css('opacity', '0.9'); //fade overlay to 1
});
return false; //stops link being followed
});