I'm new to this, 1 week of work experience in, so I apologise if there is a screamingly obvious solution to this problem. I had a quick look at similarly titled posts but couldn't find anything I could use.
I've been working on a form that has collapsable sections so that when the user has completed one section, they can click a sectionbar and it will collapse that division while the rest of the form stays open. I have achieved this fine using the following code
$('#options').click(function() {
$('div.options').toggle('slow');
return false;
});
$('#options2').click(function() {
$('div.options').toggle('slow');
return false;
});
$('#clientdetails').click(function() {
$('div.clientdetails').slideToggle('100');
return false;
});
$('#clientaddress').click(function() {
$('div.clientaddress').slideToggle('100');
return false;
});
$('#groupoptions').click(function() {
$('div.groupoptions').slideToggle('100');
return false;
});
$('#bookingoptions').click(function() {
$('div.bookingoptions').slideToggle('100');
return false;
});
$('#dataexchangeoption').click(function() {
$('div.dataexchangeoption').slideToggle('100');
return false;
});
$('#invoice').click(function() {
$('div.invoice').slideToggle('100');
return false;
});
$('#contacts').click(function() {
$('div.contacts').slideToggle('100');
return false;
});
$('#notes').click(function() {
$('div.notes').slideToggle('100');
return false;
});
$('#tasks').click(function() {
$('div.tasks').slideToggle('100');
return false;
});
Then the parts of each section is simply marked with id or class tags for their respective division. However obviously this is a hell of a lot of commands which are essentially the same thing with some tags swapped. Is there a way of compiling all of these into 1 function that will still enable me to allow distinct divisions to collapse? Any help would be greatfully recieved and appologies again if it's really obvious.