I have the following code below. Id like to replace the highlighted section with a single line of code that will run all that code. The reason behind this is because i reuse this code a lot, and would save me a lot of time by being able to copy and paste a single line of code.
Any ideas on the best way to write this?
This is the part i would like replacing with a single line of code.
$(".menu-item-1").show();
$(".menu-item-2").show();
$(".menu-item-3").show();
$(".menu-item-4").show();
$(".menu-item-5").show();
$(".menu-item-6").show();
And the entirety of the code below.
if (index == 2) {
$("#prev").show();
$("#next").show();
$(".menu-item-1").show();
$(".menu-item-2").show();
$(".menu-item-3").show();
$(".menu-item-4").show();
$(".menu-item-5").show();
$(".menu-item-6").show();
$("#p3-1").delay(1000).fadeIn("slow", function () {
$("#p3-2").delay(500).fadeIn("slow", function () {
$("#p3-3").delay(500).fadeIn("slow", function () {
$("#p3-4").delay(500).fadeIn("slow", function () {
$("#p3-5").delay(500).fadeIn("slow", function () {
$("#p3-6").delay(500).fadeIn("slow", function () {
$("#p3-7").delay(500).fadeIn("slow")
$("#next").show();
});
});
});
});
});
});
}
should be
jQuery allows you to apply same effect to multiple selectors.