I'm even stated surprised about jQuery's dumb way to put a hover attribute on an element. Take a look at this sample CSS:
div.test
{
width: 20px;
height: 20px;
color: #000000;
background: #FFFFFF;
}
div.test:hover
{
color: #FFFFFF;
background: #CC0000;
}
If we'd like to convert this to jQuery, we have to type the following:
$('div.test').css({
'width' : '20px',
'height' : '20px',
'color' : '#000000',
'background' : '#FFFFFF'
});
$('div.test').hover(function() {
$(this).css({
'color' : '#FFFFFF',
'background' : '#CC0000'
});
}, function() {
$(this).css({
'color' : '#000000',
'background' : '#FFFFFF'
});
});
Arn't there any better way to do this? It feels stupid to write obvious things.
Thank you in advance.