I have 15 square image divs on my page. One div is always expanded to be the double width (the blue area), as shown in this screenshot.
Now what I want to do is depending on no matter what div you click, to expand that div, and decrease the others' width. I have the code working for 1 div in particular (div number 2 to expand, div 1 to decrease)
I don't want to write the code for all 15 divs, where the other 14 are decreased etc. I wonder if there is a way to rewrite this function that it works for all divs.
Thanks in advance
$( "#expand2" ).click(function() {
if(TriggerClick==0){
TriggerClick=1;
$( ".vak2" ).animate({width: '50%',}, 1010 );
$( ".vakinnerlinks2" ).animate({marginLeft: '55%',}, 1010 );
$( ".vakinfo1" ).animate({width: '0px',}, 990 );
$( ".vakinfo1" ).css({"padding":'0px'});
}else{
TriggerClick=0;
$( ".vak2" ).animate({width: '25%',}, 990 );
$( ".vakinfo1" ).animate({width: '25%',}, 1000 );
$( ".vakinfo1" ).css({"padding":'25px'});
$( ".vakinnerlinks2" ).animate({marginLeft: '150%',}, 1010 );
};
});
});
$(".yourGivenClass").click(..and inside this function you can use$(this).parent()instead of$( ".vak2" )to access the div where the link clicked is in and$(".square").not($(this).parent())for all the other divs