javascript - Script works inline but when i move to external doesnt work? -


i made script navigation. becomes sticky navigation once scrolled top.

it works great when have @ bottom of index file via <script> tags when try place in external js file doesnt seam fire @ all.

full fiddle

heres script:

var windw = this; $.fn.followto = function ( pos ) {     var $this = this,         $window = $(windw);     $window.scroll(function(e){         if ($window.scrolltop() > pos) {             $this.css({                 position: 'fixed',                 top: "20px"             });         } else {             $this.css({                 position: 'absolute',                 bottom: '0',                 left: '0', right:'0',                 top: 'inherit'              });          }     });  }; $('#mainnav').followto( $(window).height() - ( $('#mainnav').innerheight() + $('.globalheader').innerheight() )); 

the jquery library missing must add above external script. in fiddle example click javascript text in upper right corner of javascript code tab , choose jquery version frameworks


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -