Alf*_*cis 0 html javascript css jquery
我在我的html页面中编写了一个java脚本.现在我将脚本移动到外部js文件.这是脚本(jful.js)
<script type="text/javascript">
$(function() {
// grab the initial top offset of the navigation
var sticky_navigation_offset_top = $('#catnav').offset().top;
// our function that decides weather the navigation bar should have "fixed" css position or not.
var sticky_navigation = function(){
var scroll_top = $(window).scrollTop(); // our current vertical position from the top
// if we've scrolled more than the navigation, change its position to fixed to stick to top,
// otherwise change it back to 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();
// and run it again every time you scroll
$(window).scroll(function() {
sticky_navigation();
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
现在脚本无法正常工作.我包括这样的脚本
<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>
Run Code Online (Sandbox Code Playgroud)
当我再次将脚本直接添加到HTML文档时,它可以工作!(当我们向下滚动页面时执行此脚本)问题是什么?
删除这些
<script type="text/javascript">
Run Code Online (Sandbox Code Playgroud)
和
</script>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1970 次 |
| 最近记录: |