jQuery change background on hover
Okay so the title says it all :P
Here is my code:
CSS:
- #item1,#item2,#item3,#item4,#item5{
- font-family:"Trebuchet MS", Helvetica, sans-serif;
- height:100px;
- text-shadow: 0px 1px 1px #4d4d4d;
- width:300px;
- vertical-align: middle;
- border:0;
- text-align: center;
- }
- #item2,#item4{
- background-image: url('eee50.png');
- }
- #item1,#item3,#item5{
- background-image: url('white50.png');
- }
+
- .itemhover{
- background-image:url('lightblue50.png');
- font-family:"Trebuchet MS", Helvetica, sans-serif;
- height:100px;
- text-shadow: 0px 1px 1px #4d4d4d;
- width:300px;
- vertical-align: middle;
- border:0;
- text-align: center;
- }
Tried this:
- $(this).stop(true,true).animate({ backgroundImage: 'url("lightblue50.png")' }, 'slow');
- },
- function(){
- $(this).stop(true,true).animate({ backgroundColor: "transparent"}, 'fast');
- });
and
- $('#item1, #item2, #item3, #item4, #item5').hover(function() {
- $(this).addClass('itemhover');
- }, function() {
- $(this).removeClass('itemhover');
- });
- });
But still cant make it work,can anyone help me? :P
Thanks.