Journey into MooTools: Day 4

Journey into MooTools: Day 4

Today we’ll look at making an accordion in Mootools, firstly using techniques we’ve already learnt and secondly using MooTool’s own Accordion function.

By Jack Franklin on October 30th, 2009 in Tutorials | Print This Article

Today we will actually make something half useful, first using the techniques we have learnt in the past 3 weeks and then using some of the extra functions MooTools provides. Enjoy!

window.addEvent('domready', function() {
			var headings = $$('h2');
			var content = $$('p');
			new Accordion(headings, content);
			/* content[0].getAllNext('p').setStyle('display', 'none');
			headings.addEvent('click', function() {
				var currentp = this.getNext();

				if(currentp.getStyle('display') == 'none')
				{
					currentp.setStyle('display', 'block');
					currentp.getAllPrevious('p').setStyle('display', 'none');
					currentp.getAllNext('p').setStyle('display', 'none');
				} else {
					//need to hide
					currentp.setStyle('display', 'none');
				}
			}); */

		});

Did you like it?

Help us spread the word!

About The Author

Jack Franklin
Jack Franklin
Jack is a 17 year old web designer and developer who lives in the beautiful area of Cornwall, England. Off the computer, Jack enjoys playing snooker, tennis, football and badminton. He is currently attending college and doing A-Levels in Maths, Further Maths, English and Computing.

Comments

    Toggle Trackbacks

    Do you have something to say?

    Live Comment Preview