2013-10-07 31 views

回答

0

收听滚动事件并检查scrollTop ...如果scrollTop参数达到您想要的位置,请更改链接的颜色。

0

试试这个:

$(window.parent.document).scroll(function() { 
     if($(this).offset().top >= xxx){ 
      ....change text colour... 
     } 
    } 
0

使用方法如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script> 
<script type="text/javascript"> 
$(document).ready(function(e) 
{ 
$(window).scroll(function() { 
var currpos = $(window).scrollTop(); 
if(currpos < 199) 
{ 
if(currpos > 100) 
{ 
$(".header").attr("color","red"); 
//$('#header').fadeTo(1,0.8,function(){}); 
} 
} 
else if(currpos < 299) 
{ 
if(currpos > 200) 
{ 
$(".header").attr("color","red"); 
//$('#header').fadeTo(1,0.6,function(){}); 
} 
} 
else if(currpos < 399) 
{ 
if(currpos > 300) 
{ 
$(".header").attr("color","red"); 
//$('#header').fadeTo(1,0.4,function(){}); 
} 
} 
else 
{ 
$(".header").attr("color","red"); 
} 
}); 
}); 
</script> 
</head> 
<body style="height:2000px;"> 
</body> 
</html> 

你可以在不同的窗口位置使用不同的颜色作为上述

0

使用$(window).scroll()事件可以检查窗口的位置。

并基于此,您可以相应地设置超链接颜色。

这样

$('#links a').click(function(){ 
    $(this).addClass('selected'); 
    $(this).siblings().removeClass('selected'); 
}); 

试试这个http://jsfiddle.net/TL9rh/