jQuery slideToggle(); bootstrap 3 not smooth animation

I am trying to animate my menu bar however it just drops down without the animation playing I have checked to make sure I have jQuery installed and its there. Any ideas why its just drops instead of animating as it should?

Jquerry:

var tab = $('#menu .menu')

tab.on('click', function(){
    $(this).next().slideToggle();

    });


<head>
  <meta content="width=device-width, initial-scale=1" name="viewport">
  <link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script src="js/jquery-1.12.0.min.js"></script>
<script src="js/bootstrap.min.js"></script>

<script src="js/custom.js"></script>
</head>
  <body>
    <a class="menu-bar" data-toggle="collapse" href="#menu">
                <img src="http://i.imgur.com/Bu0B6O8.png" alt="Logo" class = "logo">
            </a>
        	<div class="collapse menu" id="menu">

                <ul class="list-inline">

                    <li><a href="#home">Home</a></li>
                    <li><a href="#about">About</a></li>
                    <li><a href="#service">Services</a></li>
                    <li><a href="#info">Works</a></li>
                    <li><a href="#contact">Contact</a></li>
                </ul>
        	</div>



<section id="home" class="home">
    <div class="container">
        <div class="row">
            <div class="col-lg-12">
              <h1>Home</h1>
            </div>
        </div>
    </div>
</section>

<section id="about" class="about">
    <div class="container">
        <div class="row">
            <div class="col-lg-12">
                <h1>Profolio</h1>
                <!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>

<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Modal Header</h4>
      </div>
      <div class="modal-body">
        <p>Some text in the modal.</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

  </div>
</div>
            </div>
        </div>
    </div>
</section>

<section id="service" class="service">
    <div class="container">
        <div class="row">
            <div class="col-lg-12">
                <h1>Service</h1>
            </div>
        </div>
    </div>
</section>

<!-- Contact Section -->
<section id="info" class="info">
    <div class="container">
        <div class="row">
            <div class="col-lg-12">
                <h1>Info</h1>
            </div>
        </div>
    </div>
</section>


<section id="contact" class="contact">
    <div class="container">
        <div class="row">
            <div class="col-lg-12">
                <h1>Contact us</h1>
            </div>
        </div>
    </div>
</section>

</body>
.menu-bar {
top: 20px;
margin: 0 auto;
display: table;}
.logo {

    width: 100px;
    height: 50px;


}
.menu {
    display: none;
    width: 100%;
    padding: 30px 10px 50px;
    margin: 0 auto;
    text-align: center;
    background-color: #fff;
}
.menu ul {
    margin-bottom: 0;
}
.menu a {
    color: #333;
    text-transform: uppercase;
    opacity: 0.8;
}
.menu a:hover {
    text-decoration: none;
    opacity: 1;
}
/*deviders*/
.home{
    height: 100%;
    padding-top: 150px;
    text-align: center;
    background: #423840;
}

.about {
    height: 100%;
    padding-top: 150px;
    text-align: center;
    background: #8dd8f8;
}

.service {
    height: 100%;
    padding-top: 150px;
    text-align: center;
    background: #9D714F;
}

.info{
    height: 100%;
    padding-top: 150px;
    text-align: center;
    background: #eee;
}

.contact {
    height: 100%;
    padding-top: 150px;
    text-align: center;
    background: #fff;
}

Hi @GarrySsson! You’re attempting to select an element with the class menu being child of an element with the ID menu, but there is no such element. Maybe you meant #menu.menu (in which case the class selector would be redundant)? Within the event handler $(this).next() would be the #home section then, though.

Also, is that JS snippet your custom.js in the markup? In this case you’d need to wrap it in a $(document).ready handler, as otherwise the jQuery selector won’t return anything. Or even better, just put all your JS to the end of the body so that it will be loaded/evaluated when the DOM is completely parsed anyway. This also has the advantage that loading jQuery doesn’t delay your site from being displayed.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.