[英]Jquery hover not working in html
这是我的html页面:
<!DOCTYPE html>
<html>
<head>
<style>
.navigation ul li {
float: left;
list-style: none;
padding: 10px;
margin-top: 10px;
}
.navigation ul li a {
display: block;
text-decoration: none;
font-weight: bold;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"> </script>
<script>
$(document).ready(function(){
$(".navigation ul li a").hover(function(){
$(this).animate({ color: 'blue'}, "slow");
}, function() {
$(this).animate({ color: 'red'}, "slow");
});
});
</script>
</head>
<body>
<div class="navigation">
<ul>
<li><a href="#">Specials</a></li>
<li><a href="#">Fruits & Veg</a></li>
<li><a href="#">Food Products</a></li>
<li><a href="#">Locate store</a></li>
<li><a href="#">Fan Club</a></li>
</ul>
</div>
</body>
</html>
我想将动画悬停在颜色上,但是它不起作用。 同样, 在这里 ,它起作用。 我不知道为什么? 请帮我
您正在导入jQuery,但没有导入jQuery UI。 您这样做只是在摆弄,而不是在此处发布的代码中。
动画颜色需要jQueryUI。
嗨,您可以使用css3过渡示例,您可以尝试以下操作:
<!DOCTYPE html>
<html>
<head>
<style>
.navigation ul li {
float: left;
list-style: none;
padding: 10px;
margin-top: 10px;
}
.navigation ul li a {
display: block;
text-decoration: none;
color:blue;
font-weight: bold; transition:1s;
}
.navigation ul li a:hover {color:red;}
</style>
</head>
<body>
<div class="navigation">
<ul>
<li><a href="#">Specials</a></li>
<li><a href="#">Fruits & Veg</a></li>
<li><a href="#">Food Products</a></li>
<li><a href="#">Locate store</a></li>
<li><a href="#">Fan Club</a></li>
</ul>
</div>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.