I want to know if I can break this down to be less code.
I am setting slidetoggle to 4 different parts of the page, each div has its own id.
I hope it can be slimmed down to a few lines of code, since each div has the same slideToggle speed of 200.
Here is the code:
$(document).ready(function() {
$('#our-future-intro-slide').click(function() {
//$(".our-future-intro").delay(2400).slideDown(3600);
$(".our-future-intro").slideToggle(200);
});
$('#strategic-planning-click').click(function() {
$("#strategic-planning").slideToggle(200);
});
$('#student-learning-click').click(function() {
$("#student-learning").slideToggle(200);
});
$('#institutional-assessment-click').click(function() {
$("#institutional-assessment").slideToggle(200);
});
});
You can put more than one ID in a selector, separated by commas. Then just remove the
-clickor-slidefrom the ID of the element that was clicked.EDIT:
As @Ben Blank noted,
.our-future-introis a class, not an ID. If you can’t use an ID, then the above code could be modified as follows:EDIT:
Based on the code sample you provided, another alternative would be this:
Please note that it relies on your HTML structure staying consistent as provided.