A Simple Drop-Down Menu Using Jquery

The last two drop down menu tutorials on this blog use background images in the menu-tabs, and hence it is not so easy to customize them for your blogs. So here's a new widget code, in which you can easily change the colors of the menu so as to match with your blog.


Live demo can be seen here:
Demo1: ClubVista Blogger Template (In Green)
Demo2: JavaScript-Array (In Blue) (Widget author's blog)

To add a widget similar to these, follow these steps:

STEP1:
Log in to Blogger, go to "Layout" -> "Edit HTML"

STEP2:
Now find this code:
</head>
and immediately BEFORE/ABOVE it, paste this code:
<!--jquery-DD-Menu-Starts-->
<style type="text/css">
/* menu styles */
#jsddm
{ margin: 0;
padding: 0}

#jsddm li
{ float: left;
list-style: none;
font: 12px Tahoma, Arial}

#jsddm li a
{ display: block;
background: #324143; /*DARK-GREEN*/
padding: 5px 12px;
text-decoration: none;
border-right: 1px solid white;
width: 70px;
color: #EAFFED;
white-space: nowrap}

#jsddm li a:hover
{ background: #24313C}

#jsddm li ul
{ margin: 0;
padding: 0;
position: absolute;
visibility: hidden;
border-top: 1px solid white}

#jsddm li ul li
{ float: none;
display: inline}

#jsddm li ul li a
{ width: auto;
background: #A9C251; /*LIGHT-GREEN*/
color: #24313C}

#jsddm li ul li a:hover
{ background: #8EA344}
</style>


<!-- script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
var timeout = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{ jsddm_canceltimer();
jsddm_close();
ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');}

function jsddm_close()
{ if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{ closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{ if(closetimer)
{ window.clearTimeout(closetimer);
closetimer = null;}}

$(document).ready(function()
{ $('#jsddm > li').bind('mouseover', jsddm_open);
$('#jsddm > li').bind('mouseout', jsddm_timer);});

document.onclick = jsddm_close;
</script>
<!--jquery-DD-Menu-Stops-http://bloggerstop.net-->
Now before you save the template, make these changes in the code :
To get the HTML color codes, you can refer to this image:
http://homepages.ulb.ac.be/~dgonze/INFO/htmlcolors.png
STEP3:
and go to "Layout" -> "Page Elements"
and click on "Add a Gadget", select it as "HTML/JavaScript" type

and finally paste this code in to the new widget:
<!--BODY-CODE-->
<ul id="jsddm">
<li><a href="#">JavaScript</a>
<ul>
<li><a href="#">Drop Down Menu</a></li>
<li><a href="#">jQuery Plugin</a></li>
<li><a href="#">Ajax Navigation</a></li>
</ul>
</li>
<li><a href="#">Effect</a>
<ul>
<li><a href="#">Slide Effect</a></li>
<li><a href="#">Fade Effect</a></li>
<li><a href="#">Opacity Mode</a></li>
<li><a href="#">Drop Shadow</a></li>
<li><a href="#">Semitransparent</a></li>
</ul>
</li>
<li><a href="#">Navigation</a></li>
<li><a href="#">HTML/CSS</a></li>
<li><a href="http://bloggerstop.net">Blogger Help</a></li>
</ul>
And save the widget.

ProBlogger - Inspiring Others Realize Their Dreams!

Share this

Related Posts

Previous
Next Post »

263 comments

Write comments «Oldest   ‹Older   201 – 263 of 263   Newer›   Newest»
August 03, 2010 1:46 PM delete

Hi,
Your post has been really helpful. But I still need some help. I would like to change the tab font to another colour and bold the font. I also can't seem to know how to change the drop down tabs colour to a solid colour. Because it is currently translucent (refering to the FAQ tab of my blog). HELP! Much thanks.

http://princessfashionpalace.blogspot.com/

Reply
avatar
Anonymous
August 04, 2010 1:11 PM delete

dont mind me asking again ;;) plz help me with the above problem . looking forward for ur soution

Reply
avatar
Anonymous
August 05, 2010 12:02 PM delete

me too :)

Jack

Reply
avatar
Anonymous
August 24, 2010 10:03 AM delete

Any news please on my drop down issues?

Reply
avatar
September 06, 2010 3:36 PM delete

Hello Sai!!
Thank you very much for posting this very useful tutorial along with the multi-level drop-down menu! Really appreciate it!
I have 2 questions for you:
1)I am using the simple drop down menu on my blog http://meryeniko.blogspot.com/
The sublinks have long titles and I wish to keep them that long. These sublinks are displayed as horizontally elongated boxes. Is there a way to make the text/sublink titles go in more than one line so that they're displayed more like square-boxes?
(I noticed that the multi-level menu doesn't make these elongated horizontal boxes, but the multi-level drop down was working only in Firefox when I tested it /didnt work in either Explorer or Chrome/).

2) Also, the submenu boxes are displayed behind my right sidebar in Firefox, I tried using both #jsddm {
margin: 0;
padding: 0;
z-index: +1;
}
and
z-index: +100;
but I still have the same problem. I added a 80px bottom padding but obviously it is only a temporary solution for this issue. How can this issue be solved?

Any tips would be greatly appreciated if you find time to answer my questions.
Keep on with the good work!
Best wishes! Eniko

Reply
avatar
September 07, 2010 11:12 AM delete

1. Instead of auto-width, use a fixed width for the sub-menus.
So, change this:

#jsddm li ul li a
{ width: auto;
...
...


to this:

#jsddm li ul li a
{ width: 275px;
...
...



2. (Not sure, let's try)
Instead of adding that z-index: 100; to jsddm, add it to crosscol-wrapper.

so add this code to your tempalte (add it anywhere in the CSS section):

#crosscol-wrapper {
z-index: 100;
}

Reply
avatar
September 07, 2010 12:19 PM delete

Hello Sai!!
Thank you for the quick reply!!!

I've tried what you suggested:
question Nr 2)
#crosscol-wrapper {
z-index: 100;
}
isn't working, unfortunately.

Nr 1) I tried setting a fixed with in
#jsddm li ul li a
already, I tried it again now but it simply cuts off the rest of the lengthy text.

Is there a way to make the text go in more than one line within a box in the sublink menu?

I'm more concerned with nr 1) and not so much worried about nr 2)

Sorry for the trouble!
Appreciate any help
Eniko

Reply
avatar
raghu
September 10, 2010 11:20 AM delete

hi
i created a dropdown options in my site http://niftychartrealtime.blogspot.com/ but when i select an item it should update in the same site and in same page..how to achieve this.

Reply
avatar
September 10, 2010 6:11 PM delete

hmm...nice, i want to try this code...

Reply
avatar
September 11, 2010 3:54 PM delete

Hi Sai!

I've found the answer for my question nr 1), that is how to make the text wrap or go in more than one line in the sublink boxes.

I set the white-space attribute to "normal" instead of "nowrap".
Also, adjusted the "height" attribute to "auto" in
#jsddm li ul li a

The boxes are still displayed behind the right sidebar, though, I haven't been able to fix that yet.

Take care!
Eniko

Reply
avatar
September 21, 2010 12:38 PM delete

Hi! I facing a problem on my blog...I tried all of the above, ...but its still not working, my drop menu still hides under my post....what can i do...can anyone help?

my blog: www.bienprojects.com

Yuki

Reply
avatar
September 25, 2010 2:53 PM delete

I haven't been able to get the drop down portion of the menu to appear. I was successful in changing the colors and aligning it to my header, but am unable to get the drop down to drop down. Any hints or clues?

Reply
avatar
September 26, 2010 4:25 PM delete

hey there~ I loooove the look of this menu. It looks amazing with my site. I'm sure you're terribly busy, but I was wondering if you were thinking about ever attempting to just this code to work if it is placed right under the header? I'm just such a fan of the look of this one that I am trying to avoid finding a new code for a drop-down menu... my site is orfeevigori.blogspot.com (still under construction)

Reply
avatar
September 26, 2010 4:26 PM delete

sorry I meant "I was wondering if you were thinking about ever attempting to ADJUST this code to work if it is placed right under the header? ..."

Reply
avatar
October 02, 2010 9:06 PM delete

All of a sudden, the menu won't drop down anymore. It was fins this morning, but nothing changed. There were no edits to the template, the code, no downloads to my PC and nothing was installed.

Any idea why the drop down part is no longer showing up?

Thanks!

Reply
avatar
October 03, 2010 4:19 AM delete

That's strange, demo is still working correctly & my own top-drop-down menu is based on this widget.

Reply
avatar
October 03, 2010 12:34 PM delete

I've tried removing the code completely, then adding it again, still with no luck. I don't know why it is no longer working. If you find anything out, please let me know.

Reply
avatar
October 03, 2010 5:07 PM delete

I finally got it fixed! It turns out that if your drop-down boxes aren't showing up at all, make sure the code in Step #2 is the FIRST thing ABOVE < / head >

If it's not the first thing above the < / head > tag, then it may not work.

Reply
avatar
October 19, 2010 4:46 AM delete

I still having drop down menu behind my post. I have tried z-index:+100 but still doesnt work.

http://gaomeishoes.blogspot.com/

Reply
avatar
October 23, 2010 6:52 AM delete

hai i follow the above procedure! i didnt got the accurate in view!! plese help me, what modifications i have to do??
see iam appy in this blog.

http://photobrowser.blogspot.com/

please help me!!

Reply
avatar
November 27, 2010 12:23 AM delete

great drop down menu
ive jsut got one problem with it i'm getting 1px grey borders around the buttons even though i've deleted the only (only ones i can see/understand anyway) border attributes.
how can i get rid of the borders completely

here's my blog http://mamachicalocaweia.blogspot.com/

Reply
avatar
December 01, 2010 12:08 AM delete

hi sai. how to customize our own pictures instead of text on the drop down menu?

Reply
avatar
December 06, 2010 10:13 AM delete

Hi Sai,
I found facing problem with this drop-down menu in IE8,
the problem is the sub-menu drops immediately after the page has been loaded without the mouse moving on it

Reply
avatar
December 07, 2010 2:06 AM delete This comment has been removed by the author.
avatar
December 17, 2010 11:55 AM delete

I tried to solve my problem,n made to my requirement
this is how made,I removed complete Tabs from my theme and I got,
but I dont suggest the same solution to everyone,I think it is better to choose a theme which doesn't have Tabs in it template,to make this drop-down work in IE

Reply
avatar
Anonymous
December 29, 2010 9:34 PM delete

Hello!

It worked, just perfect. I created a dropdown, but, for some reason it goes to first two labeled in the list, but it dissapeares after. Can you have a look on my blog. I already see these tabs in my dreams..

Please, help.

Karina
http://www.movetheglobe.com/p/about-me.html

Reply
avatar
Anonymous
December 29, 2010 11:17 PM delete

Your code works for msie but not for any other browser...

What to do...?

Reply
avatar
December 30, 2010 1:55 AM delete

Instead of putting the widget over the header image, keep it below it, i.e. below the header image and above the post-area.

Reply
avatar
Lau
January 06, 2011 8:36 PM delete

How do i change the menu bar so the entire length matches the width of my blog?? Thanks!

Reply
avatar
January 16, 2011 2:45 AM delete

Hello I used this on my blog and thanks so much for putting this out there for me to use. Although I need help. It's hiding some of my sub menus. (http://theaprilsheree.com) I have played with it but I decided to leave it alone for now and just ask for assistance. Also how can I get all the tabs to show? Please take a look and let me know when you get a chance.

Reply
avatar
January 22, 2011 12:12 AM delete

thank uuu, I owe you big time ;)

Reply
avatar
January 22, 2011 12:20 AM delete

thank uuu, I owe you BIG TIME,

it works for me, only when I add more blocks (for more labels), always is left a small piece of white space (inside the menu border from the right side)

any ideas, please

Reply
avatar
January 25, 2011 11:55 AM delete

I LOVE this menu, but can't seem to get the drop down to show in IE8. It works great in firefox and chrome, but in IE there is no drop down at all! Could you help me please please please?

http://madebymadelinetest11.blogspot.com/ (this is just a test blog so I haven't customized the CSS yet to go with my template, nor have I updated the links!)

Reply
avatar
January 25, 2011 3:54 PM delete

Removing all the tabs stuff from the template as suggested above fixed the problem for me!!!! Yippeee!!!!! It now works in IE8, Firefox, and Chrome.

Reply
avatar
January 30, 2011 1:42 PM delete

hi
please help me
i have the same problem as many others.
the drop down menu goes behind the elements below. i have tried all the tips in the comments but nothing seems to help.

http://greatpetroleumblog.blogspot.com/

Reply
avatar
February 18, 2011 4:01 PM delete

I ran into the problem again in IE with the menu and an immage. This tutorial helped me finally fix it:
http://brenelz.com/blog/squish-the-internet-explorer-z-index-bug/

Reply
avatar
McKay
February 24, 2011 2:17 AM delete

Hey Sai,

You seem to know a lot here. I can't seem to get this to work. Everything is set up right, but the drop down portions of the menu drop down behind the post.

How can I get my drop down menu in front of my posts?

McKay

Reply
avatar
March 10, 2011 3:02 AM delete

Hello I am having the same problem with the drop down menus not showing up, I tried moving it around but no use. Please HELP. Thank you.

Reply
avatar
April 20, 2011 1:13 AM delete

This dropdown is much easier than in http://bloggerstop.net/2009/01/multi-level-drop-down-menu-in.html
I got it work but one thing: how I can make more level in this dropdown menu?

Reply
avatar
April 20, 2011 2:37 PM delete

Notice in the last code, every line starting from <li> and ending with a </li> code gives you a new level. So, that's it repeat that pattern according to your needs.

Reply
avatar
April 24, 2011 7:42 AM delete

Just used it on a job and it's a nice simple drop down option, worked a treat thanks !

Reply
avatar
Anonymous
May 20, 2011 12:37 AM delete

Thanks you....just see how my menu looks..
http://entertainmentking.blogspot.com/

Reply
avatar
June 03, 2011 6:15 AM delete

itz not working in my blog
www.winkship.blogspot.com
i cannot click on dropped menus????

Reply
avatar
August 08, 2011 7:09 PM delete

i tried your trick and it works on my blog. my problem now is i want to place the menu just above my blog's header but it simply doesn't work.I have a link ad above my header and i want to exchange the placement of my menu tab and the link ad. my menu menu doesn't fall in the same line. it all scattered.

you can check my blog at www.yourgateway2success.com. any help will be much appreciated. thanks a lot.

Reply
avatar
August 10, 2011 3:53 PM delete This comment has been removed by the author.
avatar
August 10, 2011 5:37 PM delete

pls check:
http://letseatsomegoodfood.blogspot.com

I have tested every single menu bar, and it keeps going under other page elements. multiple, collapse etc.

i also try adding 1, 100, +100 in the css, still it goes under page elements.

anyone, pls help me..

Reply
avatar
August 10, 2011 7:07 PM delete

mine seems working now adding z-index on all css of this code

Reply
avatar
August 25, 2011 3:42 AM delete

is it possible to add it to any template by blogspot?

Reply
avatar
September 13, 2011 7:16 AM delete

Only first item in the drop down menu is displayed. why it is so? Mu blog is http://shreyaghoshalmalayalam.blogspot.com/

Reply
avatar
September 15, 2011 9:10 AM delete

Hi..
Thanks for sharing this information and resources it's really help full for me with the help of this we can improve our designs and development I really inspire with this information thanks

Reply
avatar
October 04, 2011 8:30 PM delete

it's look good. Easy navigation for my visitor

Reply
avatar
November 02, 2011 11:42 PM delete

why i cant post my comment here? it says.. you dont have permision to view this blog? whats the prob?

Reply
avatar
November 17, 2011 2:29 AM delete

The whole work is appreciable which is clearly defined here by the admin of blog. I never would have thought about it before. I definitely savored every single small bit of it because it’s very useful info for every blog maker. I just would like to say that carry your precious work on regular bases because it’s really knowledge plus for readers.

Reply
avatar
December 24, 2011 5:39 PM delete

thanks a lot for sharing , jquery is helpful stuff

Reply
avatar
January 20, 2012 5:04 AM delete

can u tell me in details about the drop down menu bar... i cant display it on me blog..if u got some free time please go to my blog so we can have so chat... :)

http://shinetourism-academy.blogspot.com/

Reply
avatar
Anonymous
April 12, 2012 10:30 PM delete

hi,

great blog..i found almost everything that i need here..
however, i have a question. i also added the forum (that i also read from your blog and it works perfect!). my question is my submenu in the dropdown are hiding behind the forum..

pls help..
thanks.

Reply
avatar
July 18, 2012 12:51 AM delete

I've been removed ur dd menus from my blog cos of u didn't help me nor aswer my question at all....i've been asked u twice and linkedin ur url to all my site also giving u help by always visit&clickin ur ads/sponsor and many more,,,but u never answer all my question!
i want to ask u once again about my homework that my boss giving it to me now....but,i think i better NOT TO ASK U FOR THE THIRD TIME....!
really dissappointing me...
:-L

Reply
avatar
September 22, 2015 5:55 PM delete This comment has been removed by a blog administrator.
avatar
«Oldest   ‹Older   201 – 263 of 263   Newer›   Newest»

Comments are moderated on this blog

Allowed HTML tags: <b>, <i> and <a>

Comment Like This! and Optimize your blog EmoticonEmoticon