javascript - jQuery functions never getting executed on .ready() -


i'm little new jquery , having issue wiring click events. if put alert(''); can see menu.js referenced when alert inside .ready() function alert never triggered...

jsfiddle: click here

could kind enough point out issue? thanks!

html

 <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head>     <title>menu demo</title>     <link href="content/themes/base/minified/jquery-ui.min.css" rel="stylesheet" />     <link href="content/menudemo.css" rel="stylesheet" /> </head> <body>     <div class="navbar">         <img id="navbar-logo" src="content/images/ingr_logo.png" class="ui-button-icon-primary">         <img id="navbar-logo" src="content/images/smaller.png" class="image-right">     </div>     <div id="menu1" class="floating-menu ui-menu">         <div class="floating-menu-header">             <div class="floating-menu-header-text">example menu</div>             <div class="grip"></div>             <div><img id="expand1" src="content/images/expand.png" class="floating-menu-header-icons"></div>             <div><img id="drag1" src="content/images/lock-add.png" class="floating-menu-header-icons locked"></div>             <div><img id="close1" src="content/images/close.png" class="floating-menu-header-icons"></div>         </div>         <div class="floating-menu-body"></div>     </div>     <div id="menu2" class="floating-menu ui-menu">         <div class="floating-menu-header">             <div class="floating-menu-header-text">example menu</div>             <div class="grip"></div>             <div><img src="content/images/expand.png" class="floating-menu-header-icons"></div>             <div><img src="content/images/lock-add.png" class="floating-menu-header-icons locked"></div>             <div><img src="content/images/close.png" class="floating-menu-header-icons"></div>         </div>         <div class="floating-menu-body"></div>     </div>     <div id="menu3" class="floating-menu ui-menu">         <div class="floating-menu-header">             <div class="floating-menu-header-text">example menu</div>             <div class="grip"></div>             <div><img src="content/images/expand.png" class="floating-menu-header-icons"></div>             <div><img src="content/images/lock-add.png" class="floating-menu-header-icons locked"></div>             <div><img src="content/images/close.png" class="floating-menu-header-icons"></div>         </div>         <div class="floating-menu-body"></div>     </div>     <div id="menu4" class="floating-menu ui-menu">         <div class="floating-menu-header">             <div class="floating-menu-header-text">example menu</div>             <div class="grip"></div>             <div><img src="content/images/expand.png" class="floating-menu-header-icons"></div>             <div><img src="content/images/lock-add.png" class="floating-menu-header-icons locked"></div>             <div><img src="content/images/close.png" class="floating-menu-header-icons"></div>         </div>         <div class="floating-menu-body"></div>     </div>     <!-- scripts-->     <script src="scripts/libs/jquery-2.1.1.min.js" type="text/javascript"></script>     <script src="scripts/libs/jquery-ui-1.10.4.min.js" type="text/javascript"></script>     <script src="scripts/site/menu.js" type="text/javascript"></script> </body> </html> 

menu.js

/// <reference path="../jquery-2.1.1.js" /> /// <reference path="../jquery-ui-1.10.4.js" />  // make menus draggable function makemenusdraghandler() {     $('.locked').click(function () {         $('.floating-menu').draggable();      }); }  // collapse/expand height of navbar  function smallbignavbarhandler() {     $('.image-right').click(function () {         var navbar = $('.navbar');         navbar.height(navbar.height() === 51 ? 30 : 15);     }); }  $(document).ready(function ($) {     // add handlers     smallbignavbarhandler();     makemenusdraghandler();     // setters }); 

proj struct

you have 2 issues:

  • you don't have jquery included
  • see below

this line:

navbar.height = navbar.height() === 51 ? 30 : 15; 

should be:

navbar.height(navbar.height() === 51 ? 30 : 15); 

the setter is:

.height(value) 

and not

.height = value 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -