What is it?
Sweet Menu takes an ordinary unordered list of links and makes it a sweet looking menu. It does this by utilizing jQuery and it’s plugin system. Simply include the jQuery library, the Sweet Menu plugin, and make a simple jQuery call and you are on your way to a sweet looking menu!
How to use it!
The usage of Sweet Menu is like any jQuery method. Basically, call the jQuery object and pass in your selector with our method call of sweetMenu(). The most basic call would like like this:
$(selector).sweetMenu();
Please keep in mind that this method is meant to only work on one DOM element passed in, and because of that, if you use a jQuery selector that selects multiple DOM elements, Sweet Menu will only work on the first DOM element jQuery gets. Sweet Menu does return the jQuery object based on the selector used.
When calling Sweet Menu, you want to make sure you point it at a list of unordered links, the HTML structure should look like this:
<ul id="mySweetMenu"> <li> <a href="#link1"> Link 1 </a></li> <li> <a href="#link2"> Link 2 </a></li> </ul>
Arguments
There is only one argument for Sweet Menu, and it is an optional argument. The one argument is a list of optional properties. Here are the properties, with descriptions and examples, that can be used with the Sweet Menu plugin.
| Property | Description |
|---|---|
| top |
This is the number of pixels from the top of the screen that the first menu item will appear. $(selector).sweetMenu({top: 80}); |
| position |
This is the CSS position of the menu as a whole. By selecting the fixed option, the menu stays fixed to the screen, meaning when you scroll down the menu scrolls too. By selecting the absolute option, the menu will stay hooked to the top of the screen, so when you scroll down the menu will eventually disappear. $(selector).sweetMenu({position: 'fixed'}); |
| iconSize |
This is a short-hand property for passing in square icons. It sets the iconSizeWidth and iconSizeHeight properties to the integer passed in to this property. Note, size is meant to be measured in pixels. $(selector).sweetMenu({iconSize: 20}); |
| iconSizeWidth |
This is the width in pixels of icons being used, if any, by the menu. $(selector).sweetMenu({iconSizeWidth: 40}); |
| iconSizeHeight |
This is the height in pixels of the icons being used, if any, by the menu. $(selector).sweetMenu({iconSizeHeight: 20}); |
| padding |
This is the padding in pixels between the text, the icons and the borders of the menu item.
$(selector).sweetMenu({padding: 8}); |
| verticalSpacing |
This is the vertical distance, in pixels, between each menu item. $(selector).sweetMenu({verticalSpacing: 5}); |
| duration |
This is the duration of the animation when the menu pops “in” or “out”. Anything you can pass into the jQuery animate method, you can pass into this property. $(selector).sweetMenu({duration: 'slow'}); // or $(selector).sweetMenu({duration: 250}); |
| easing |
Any easing function registered to jQuery can be used here. $(selector).sweetMenu({easing: 'easeOutBounce'}); |
| anchorClass |
This is the class name that is appended to the anchor of the menu item. It is only used for additional or extra styling. Note, any styling that interferes with the function of the menu will be overridden by the plugin. For instance, if you define padding in your CSS for the anchor class, the plugin will still use the padding defaulted by the plugin or what was passed in. $(selector).sweetMenu({anchorClass: 'myClass'}); |
| openFinished |
This function is called after the menu item is fully displayed. $(selector).sweetMenu({openFinished: function() { alert('The tab is open!'); }}); // or var myFunction = function() { alert('The tab is open!'); } $(selector).sweetMenu({openFinished: myFunction}); |
| closeFinished |
This function is called after the menu item is “closed” or no longer fully displayed. $(selector).sweetMenu({closeFinished: function() { alert('The tab is closed!'); }}); // or var myFunction = function() { alert('The tab is closed!'); } $(selector).sweetMenu({closeFinished: myFunction}); |
| icons |
This property defines image paths for any icons to be used in the menu. The icon paths should be in the form of a string and will be applied to the menu items in the order they are passed in. If there are not enough icons for all of the menu items, the menu items at the end of the menu list will not have icons. If there are too many icons, the extra icons are ignored. $(selector).sweetMenu({icons: ['one.png', 'two.png', 'three.png']}); |
Versions
- Verstion 1.0 — Initial version


Pingback
by Sweet Menu, a new jQuery plugin
26 Aug 2010 at 20:50
[...] Sweet Menu [...]
by enam
26 Aug 2010 at 23:16
very nice work…i just love this…keep it up.
by borith
15 Sep 2010 at 20:48
Very nice and excellent. But it doesn’t work in IE6
by adam
16 Sep 2010 at 13:25
You are correct @borith.
I may decide to change this in the future, but for my initial release, I didn’t want to put any effort toward supporting IE6. However, Sweet Menu, does fail gracefully, without JavaScript errors, and retains your original unordered list.
by David van der Sluis
29 Sep 2010 at 01:55
Nice plugin. The source is tidy and the comments in it suffice.
In IE I got the this strange markup glitch, where somehow the width got screwed up when used with the Lay-out plugin and DIV’s within in it and it consistently came up 110px short in IE (actually 113 according to FireFox:Web Developer) no matter what the size was of the text.
I suspect it has something to do with the li width ignoring the link width…. but when I re-set it in the 2nd css() iteration (the offset in the first css() didn’t work) with the offset it works flawlessly!
I fixed it with:
//DS: is FUBAR-ed in IE
var browseroffset = 0;
if($.browser.msie){
browseroffset = 110;
}
// apply our margin left to our anchors
jQuery(this).children(‘li’).children(‘a’).css({
‘position’: ‘absolute’,
‘width’ : settings.width + browseroffset + ‘px’,
‘left’: ‘-’ + settings.marginLeft + ‘px’
});
by borith
30 Sep 2010 at 01:25
Hi, David van der Sluis,
can you publish the script that you have updated to work with IE. I want to use it IE.
Thanks in advance.
by adam
30 Sep 2010 at 08:20
Thanks for the comments David.
In what version of IE are you seeing this problem? So far I have not been able to reproduce the problem.
Also, out of curiosity, why do you use a DIV inside your list?
by David van der Sluis
05 Nov 2010 at 09:05
@borith: I’ll look into it
@adam:
IE version was IE8. It did it only when used with the Lay-out plugin. Had the lay-out render a left pane with the width of sweetmenu and a big right pane with nested panes.
As for the divs: I had some bubbling issues with binding hover events and DIV’s seem to solve it (haven’t been bothered to look into it further)
by akin
14 Nov 2010 at 15:42
Thank you Adam, it is very sweet!
I love it!
thank you again for your great job!
by 云端月空
17 Nov 2010 at 03:48
thanks ,I love
by SRADHANAND
18 Nov 2010 at 22:04
Excellent menu
by ask
29 Nov 2010 at 18:16
is it possible sweet menu in the right?
by adam
29 Nov 2010 at 22:40
Currently, the menu doesn’t support being on the right hand side. Also, with the way I am doing it, I know it will make a horizontal scroll bar, but it might be possible. You aren’t the first person to ask me, so I will put some thought into it and let you know.
by adam
01 Dec 2010 at 13:37
Well, as a proof of concept, I’ve come up with a way to do it.
I will look into wrapping up this change into the next official release, which should be released within a week.
by sarankumar
04 Dec 2010 at 04:27
very very nice u really rockingggggg
Pingback
by jQuery Menus with Stunning Animations - Noupe Design Blog
17 Feb 2011 at 02:22
[...] Sweet Menu Sweet Menu takes an ordinary list of links and makes it a sweet looking menu. It does this by utilizing jQuery and it’s plugin system: [...]
Pingback
by Week in Web: jQuery Menus, Flowplayer update, Stylesheet removal, drop shadows, Gury, Sliders, etc | Sean Walther’s Blog
18 Feb 2011 at 09:04
[...] Noupe.com, covering some very nice jQuery menu ssytems, including:Scrollable Thumbs Menu with jQuerySweet MenuCreating a Fancy Menu Using CSS3 and jQueryRocking and Rolling Rounded Menu with jQuerySlick [...]
Pingback
by Collection Of jQuery Navigation Menus with Awesome Animations | Webwibe
03 Mar 2011 at 04:35
[...] Sweet Menu Sweet Menu takes an ordinary list of links and makes it a sweet looking menu. It does this by utilizing jQuery and it’s plugin system: [...]
Pingback
by 30+ jQuery Plugins and Scripts for Web Designers 2011 | Web Design Zo
24 Mar 2011 at 08:14
[...] Demo & Download [...]
by Martina Breithaupt
29 Mar 2011 at 13:44
Wow, looks awfully a lot like this one:
http://tympanus.net/codrops/2009/11/30/beautiful-slide-out-navigation-a-css-and-jquery-tutorial/
by rlsgame
02 Apr 2011 at 11:32
it will be grait if the sweet menu in the right
by Inger
19 Apr 2011 at 12:58
Adam, I’d LOVE to see your menu executed on the right side, too. I think a right-side menu has more applications. My attempts at tweaking the jquery code haven’t worked.
by adam
19 Apr 2011 at 14:24
Do to the way I hide the collapsed menu (asolute positoning) this menu only works on the left. However, I figured out a way that I am working on to make the menu work on both the left and the right (using width and hidden overflow). So an update is coming soon (as well as a new site devoted to this type of work).
by Inger
25 Apr 2011 at 14:59
Adam, really looking forward to seeing this. Appreciate the work involved.
by adam
16 May 2011 at 23:44
I am still working on updates for this jQuery plugin, I just can’t seem to work out the bugs with the right hand side menu. With my limited time do to my normal job, freelance stuff, and family life I haven’t had a ton of time to work on it. I will try to get it out as soon as possible.
by Steven Tew
25 Jul 2011 at 02:59
A very nice effect. I think keyboard access should be added in your next release; the tabs should slide out as navigate the page using the keyboard so I can tell where I am in the page.
by Arturo
07 Aug 2011 at 11:53
Hi! How to to open double-click or failing to stay open all the time? I am using this menu on a touch screen and a touch I want to open and another from the link. I can not. Greetings and thanks!
by adam
08 Aug 2011 at 10:52
I have re-written this plugin a few times now and keep running into issues with trying to support both left-hand and right-hand placement. I apologize for not getting that support in sooner, but I’ve been so busy with other projects.
This site is going to change hosts in the near future and at that point I am going to move this project over to Git in hopes that you guys are able to help me keep this plugin up-to-date.
I want to be able to update this plugin more often but I don’t see it happening anytime soon.
by David van der Sluis
16 Nov 2011 at 02:08
@Adam
Let me know when you have transferred the source into Git.
by Jay
31 Jan 2012 at 05:36
Hey, do you still have the demo and download available? The links are not working and I would love to see this.
Cheers
by adam
31 Jan 2012 at 10:09
Jay-
I haven’t given my blog love in a while, the download links are there, but they don’t look like links. Sorry about that. Here are the links to the demo and the download:
http://playground.adambecker.info/sweet-menu/
http://playground.adambecker.info/sweet-menu/sweet-menu-latest.zip
I hope you enjoy it,
Adam
by adam
31 Jan 2012 at 10:15
@David
I’ve also added this puppy into Git. Sorry that has been long waiting, but here you go!
https://github.com/cyphun/Sweet-Menu
I’m hoping to make some overhauls to this site in the near future. Been working on some cool new projects that I would like to share with you all.
Adam