jquery - JavaScript not working when moved to an external .js file -
i had working java script in html page.now moved script external js file. here script(jful.js)
<script type="text/javascript"> $(function() { // grab initial top offset of navigation var sticky_navigation_offset_top = $('#catnav').offset().top; // our function decides weather navigation bar should have "fixed" css position or not. var sticky_navigation = function(){ var scroll_top = $(window).scrolltop(); // our current vertical position top // if we've scrolled more navigation, change position fixed stick top, // otherwise change relative if (scroll_top > sticky_navigation_offset_top) { $('#catnav').css({ 'position': 'fixed', 'top':0, 'left':0 }); } else { $('#catnav').css({ 'position': 'relative' }); } }; // run our function on load sticky_navigation(); // , run again every time scroll $(window).scroll(function() { sticky_navigation(); }); }); </script>
now script not working. included script
<head><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> <script type="text/javascript" src="jful.js"></script></head>
when again add script directly html document ,it works !(this script execute when scroll down page ) problem ??
remove these
<script type="text/javascript">
and
</script>
Comments
Post a Comment