i have a easy problem, i need do a action .click() if is clicked on a div in my array...
if($('#container_1').click(function(){
$('div#image').fadeOut('fast', function(){
$('div#cat_1').css('background-color', '#F30');
$('#new_frame').show('fast').load('history.html');
});
}));
if($('#container_2').click(function(){
$('div#image').fadeOut('fast', function(){
$('div#cat_2').css('background-color', '#F30');
$('#new_frame').show('fast').load('history.html');
});
}));
if($('#container_3').click(function(){
$('div#image').fadeOut('fast', function(){
$('div#cat_3').css('background-color', '#F30');
$('#new_frame').show('fast').load('history.html');
});
}));
if($('#container_4').click(function(){
$('div#image').fadeOut('fast', function(){
$('div#cat_4').css('background-color', '#F30');
$('#new_frame').show('fast').load('history.html');
});
}));
if($('#container_5').click(function(){
$('div#image').fadeOut('fast', function(){
$('div#cat_5').css('background-color', '#F30');
$('#new_frame').show('fast').load('history.html');
});
}));
Okay that is my code what works...
But i think that i can to do so much shorter... with a code like this::
Contenedores = ['1', '2', '3', '4', '5'];
if($('#container_'+Contenedores).click(function(){
$('div#image').fadeOut('fast', function(){
$('div#cat_'+Contenedores).css('background-color', '#F30');
$('#new_frame').show('fast').load('history.html');
});
}));
But i don't know how do it right to work...
Thanks, and sorry my poor english.
ifparts or am I missing something?