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

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -