Đối với một số lý do, tôi chỉ không thể có được hiệu ứng di chuột để làm việc
HTML:Hiệu ứng jQuery Hover cho NavBar không hoạt động?
<div id="navbarcontainer">
<ul>
<li id="left" class="current">
<a id="current">Home</a></li>
<li class="dependant1">
<a id="dependant1">Services</a></li>
<li id="right" class="dependant2">
<a id="dependant2">Contact</a></li>
</ul>
</div>
CSS:
#navbarcontainer {
margin: 0;
padding: 0;
height: 50px;
background: #01216D;
}
#navbarcontainer ul {
clear: both;
margin: 0;
padding: 0;
list-style: none;
}
#navbarcontainer li {
display: inline-block;
height: 50px;
width: 100px;
list-style: none;
text-align: center;
-moz-transition: .5s;
-o-transition: .5s;
-webkit-transition: .5s;
transition: .5s;
/* Firefox 4 */
/* Opera */
/* Safari and Chrome */
}
#navbarcontainer ul li a {
text-decoration: none;
line-height: 50px;
width: 100px;
font-size: 20px;
font-family: Calibri;
cursor: pointer;
}
#left {
margin-right: 40px;
margin-left: 20px;
}
#right {
margin-left: 40px;
}
.current {
background: #fff;
}
#current {
color: #01216D;
font-weight: bold;
}
#dependant1, #dependant2 {
color: #fff;
}
jQuery:
$("#dependant1").hover(function() {
$('.dependant1').stop().animate({background: '#fff' }, "slow");
$('#dependant1').stop().animate({color: '#01216D', 'font-weight': 'bold'}, "slow");
}, function() {
$('.dependant1').stop().animate({ background: 'none' }, "slow");
$('#dependant1').stop().animate({color: '#fff', 'font-weight': 'normal'}, "slow");
});
tôi cảm thấy như nó có một cái gì đó để làm với jQuery, nhưng tôi có nó trong document.load, vì vậy tôi không hiểu tại sao nó không hoạt động.
Các jQuery mã được hiển thị chỉ là một thử nghiệm để thử hiệu ứng di chuột, vì vậy tôi biết nó sẽ chỉ hoạt động trên một liên kết – Karmaxdw
bạn không thể tạo hiệu ứng 'color' và' background' chỉ với jQuery, sử dụng jQuery UI –
Giải quyết, cảm ơn bạn. – Karmaxdw