Hi! I am looking to make an adjustment to this script. I'm trying to find a way to do it as neatly as possible, and without breaking any pre-existing functionality.

The code is here, with its corresponding tutorial:

http://tympanus.net/codrops/2011/03/28/moving-boxes-content/

What I'm trying to do is have the first section open by default. What makes this a challenge for me is that the boxes that assemble to create the content wrapper are drawn on page initialization.

Any suggestions would be greatly appreciated, and I'll do my best to pay it forward.

Recommended Answers

ari$av3s,

I think it's easy (but I have said that before).

(untested) In the demo script, try adding right at the bottom of the $(function() {...}); a line, which stimulates a click on the first menu item:

/*
	call the init method of Menu …
Jump to Post

All 3 Replies

ari$av3s,

I think it's easy (but I have said that before).

(untested) In the demo script, try adding right at the bottom of the $(function() {...}); a line, which stimulates a click on the first menu item:

/*
	call the init method of Menu
*/
	Menu.init();
	$("#mb_menu a").eq(0).click();//this is the added line
});

Airshow

commented: Elegant solution! +0

An elegant and simple solution. Thank you! I am guessing that same line be modified [with appropriate div] to simulate a first click in any similar setup?

An elegant and simple solution. Thank you! I am guessing that same line be modified [with appropriate div] to simulate a first click in any similar setup?

Yes, exactly so.

If you can identify the required element with a jquery selector (and/or selection methods), and it's clickable, then .click() simulates the user interaction left-single-click (though not in every respect - for example, the "clicked" element does not take focus).

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.