0

Hi I am trying to make a drop down menu. This may be a basic question but I am trying to make it work for the last hour or so but I do not know what is the problem in my code.

The problem is when I hover over the link then it should display drop down links but it does not show it.

Please check my code over here jsfiddle

EDIT

It works in jsfiddle but still it is not working for my here locally

here is my code

<html>
<head>
<style>
body {
    font-family: Arial;
}
.top-nav {
    list-style: none;
    margin:0; padding: 0;
}
.top-nav li {
    position: relative;
    width: 100px; height: 60px;
    display: block;
    float: left;
    margin-right: 1px;
}
.top-nav li a {
    width: 100px; height: auto;
    display: block; text-align: center;
    background: #cccccc; padding: 27px 0 17px 0;
    text-decoration: none; color: #6b6d6e;
}
.top-nav li a:hover {
    background: lightblue;
    color: #fff;
}
/*---------------------------*/
.top-nav li ul {
    padding: 0; margin: 0;
    list-style: none;
    display: none;
}
.wrap {
    -webkit-box-shadow: 0 0 9px #c0c0c0;
    width: 490px; height: 250px;
    padding: 2px 3px;
}
</style>
<script src="jquery.js" type="text/javascript" charset="utf-8"></script>
<script type='text/javscript'>
$(function() {
    $('.top-nav li').hover(function() {
        $('ul',$(this)).show();
    },function() {
        $('ul',$(this)).hide();
    });
});
</script>
<title></title>
</head>
<body>
    <ul class='top-nav'>
        <li><a href='#'>Menu</a>
            <ul>
                <li>
                    <div class='wrap'>Stuff Here</div>
                </li>
            </ul>
        </li>
        <li><a href='#'>Products</a>
            <ul>
                <li>
                    <div class='wrap'>Stuff Here</div>
                </li>
            </ul>
        </li>
    </ul>
</body>
</html>
8
  • Is it not working in jsfiddle you mean ? There is no prblem with your code, you have to select "jQuery" in the framework panel on the left... Commented Feb 19, 2012 at 7:30
  • I added the framework from the left panel now it is working in jsfiddle. Thats what I said in above update that it works in jsfiddle BUT it is not working locally on my computer. I added jquery library there but still not working. I do not know why? Commented Feb 19, 2012 at 7:41
  • Difficult for us the know what is not working on your computer. Do you get any error in the browser's javascript console (press F12 to display it) ? Commented Feb 19, 2012 at 7:42
  • when I add this line to my code $(function() {alert('hello');}); then when I reload my page it does not even alert anything. Commented Feb 19, 2012 at 7:47
  • 2
    There is also one typo in your html: type='text/javscript' should be type='text/javascript' Commented Feb 19, 2012 at 7:53

5 Answers 5

1

I think you forgot to load the jquery library on the left nav bar. Check it now http://jsfiddle.net/rsarika/vAPHq/1/

Sign up to request clarification or add additional context in comments.

Comments

1

It works. You should remember to load jQuery.

Comments

1

You didn't choose the framework is 'jQuery' :)

Comments

1

You have a typo in the piece of code you added:

<script type='text/javscript'>  // missing a "a" in "javscript"

should be

<script type='text/javascript'>

Comments

1

Check out the corrected jsFiddle.

Also, check out that you've selected jQuery from the selectbox on the left.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.