【发布时间】:2013-06-10 18:07:51
【问题描述】:
我正在使用 jQuery 函数 .animate 来一一突出导航链接。它们在 ul 中。我可以让它工作,只是想知道是否有办法缩短我的代码,这样我就不必单独突出显示每个项目。提前致谢
$(document).ready(function(){
$('#button1').mouseenter(function(){
$(this).animate({
color:"#FFFFFF",
backgroundColor: "#FF9B05"
});
});
$('#button1').mouseleave(function(){
$(this).animate({
color:"#FF9B05",
backgroundColor: "#FFFFFF"
});
});
$('#button2').mouseenter(function(){
$(this).animate({
color:"#FFFFFF",
backgroundColor: "#FF9B05"
});
});
$('#button2').mouseleave(function(){
$(this).animate({
color:"#FF9B05",
backgroundColor: "#FFFFFF"
});
});
$('#button3').mouseenter(function(){
$(this).animate({
color:"#FFFFFF",
backgroundColor: "#FF9B05"
});
});
$('#button3').mouseleave(function(){
$(this).animate({
color:"#FF9B05",
backgroundColor: "#FFFFFF"
});
});
$('#button4').mouseenter(function(){
$(this).animate({
color:"#FFFFFF",
backgroundColor: "#FF9B05"
});
});
$('#button4').mouseleave(function(){
$(this).animate({
color:"#FF9B05",
backgroundColor: "#FFFFFF"
});
});
});
【问题讨论】:
标签: jquery navigation jquery-animate