user520300
user520300

Reputation: 1527

slideToggle on page load

I have this jQuery code which toggles a container on click

// START JQUERY TOGGLE SUBMENUS
jQuery(document).ready(function() {
  jQuery(".toggle_container").hide();
  jQuery("li.trigger a").click(function() {
    jQuery(".toggle_container").hide();
    jQuery(this).toggleClass("active").next().slideToggle("slow");
  });
});

how can i open a specific item on page load?

Upvotes: 0

Views: 1735

Answers (1)

mVChr
mVChr

Reputation: 50205

Add this to the end of your (document).ready:

jQuery("li.trigger a").eq(0).click();

This will click the first li.trigger a. Change the value in .eq() to be whichever item you want opened on page load, starting from 0.

Upvotes: 1

Related Questions