treehouse : what would you like to learn today?
Web Design Web Development iOS Development

slideToggle

  • this code is virtually the same as what I'm using on another site and works perfectly yet is not working on another site. If you can highlight where I'm going wrong I would be grateful.

    jQuery

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script&gt;
    <script type="text/javascript">
    $(document).ready(function(){

    $("#port").click(function(){
    $("#subNav").slideToggle("slow");
    $(this).toggleClass("active"); return false;
    });
    });
    </script>


    HTML
    <div id="leftSidebar">
    <ul id="nav">
    <li id="hm">home</li>
    <li><a href="#" id="port">portfolio</a></li>
    <ul id="subNav">
    <li><a href="#">kitchens</a></li>
    <li><a href="#">bathrooms</a></li>
    <li><a href="#">bedrooms</a></li>
    <li><a href="#">other</a></li>
    </ul>
    <li><a href="about.html" id="ab"=>about</a></li>
    <li><a href="contactPage2.html" id="con">contact</a></li>
    </ul>
    </div>
  • The code as you pasted it above, seems to work fine, I don't think there's anything wrong with it. If it's working on one site, but not another, then I'd say that the site where it's not working has some other code somewhere that's getting in the way.