我正在尝试在 JQuery 中使用背景动画方法,但它不起作用。这是我正在使用的代码。
$(".menu_item").mouseenter(function(){$(this).animate({backgroundColor: "#FF8040"}, 'fast');});
$(".menu_item").mouseleave(function(){$(this).animate({backgroundColor: "#999"}, 'fast');});
感谢任何帮助。
这是其余的。
菜单的 HTML:
<div id="menu">
<a href="index.html" id="home_menu" class="menu_item">Home</a>
<a href="index.html" class="menu_item">Tutorials</a>
<a href="index.html" class="menu_item">News</a>
</div>
和脚本:
<script type="text/javascript">
$(document).ready(function(){
jQuery().ready(function(){
$(".menu_item").mouseenter(function(){$(this).animate({backgroundColor: "#FF8040"}, 'fast');});
$(".menu_item").mouseleave(function(){$(this).animate({backgroundColor: "#999"}, 'fast');});
var pos = $("#fixed_head").position();
var height = $("#fixed_head").height();
var height2 = $("#menu").height();
var screenHeight = $("body").height();
var newHeight = screenHeight - height - height2;
$("#container").css("top", (pos.top + height));
$("#container").css("height", newHeight);
$("#content").css("height", newHeight);
$(window).resize(function() {
var pos = $("#fixed_head").position();
var height = $("#fixed_head").height();
var height2 = $("#menu").height();
var screenHeight = $("body").height();
var newHeight = screenHeight - height - height2;
$("#container").css("top", (pos.top + height));
$("#container").css("height", newHeight);
$("#content").css("height", newHeight);
});
});
});
</script>
在头脑中:
<script type="text/javascript" src="jquery.js"></script>