2010-10-18 60 views
0

让我说我通过url,example.php?mode = select & ID = 1#年龄jQUery基于url的淡入?

是否有可能基于url添加jQuery fadeIn?

该网址将在另一个页面上,当用户点击,页面将加载,因此提交的年龄应该是褪色英寸

如果这不可能,有没有其他办法?

回答

2

您可以检查是否有一个location.hash集上document.ready如果是的话,请拨打.fadeIn()该元素上,像这样:

$(function() { 
    if(location.hash) $(location.hash).fadeIn(); 
}); 

因此,举例来说,如果您的网址为....#age,这会褪色的id="age"元素。

0

我已经做了类似的东西,像这样的URL:

http://site.com/page/view/#219

var theHash = window.location.hash; 
theHash=theHash.substr(1); 

$("#f"+theHash).css('backgroundColor',"#E47527"); 
$("#f"+theHash).animate({backgroundColor: "#ffefe3" }, 2000); 

可能更有效的方法,但是。在ID为“#f111”的链接上使用