What about this instead? I think your version will suffer from performance penalties.
$('.navbarItem').hover( function () { // Mouse over, first hide previous gradients for all other navigation elements. $('.navbarItem').children(".gradient").hide(); if ($(this).hasClass('hasGradient')) { // Show the gradient for this item. $(this).children('.gradient').show(); } else { // Create a new gradient for this element $(this).addClass('hasGradient').gradient({ from: 'dddddd', to: 'aaaaaa' }); } }, function () { // Mouse out (this doesn't always get called - must be a bug), hide the gradient. $('.navbarItem').children(".gradient").hide(); } );
What about this instead? I
What about this instead? I think your version will suffer from performance penalties.
$('.navbarItem').hover(function () {
// Mouse over, first hide previous gradients for all other navigation elements.
$('.navbarItem').children(".gradient").hide();
if ($(this).hasClass('hasGradient')) {
// Show the gradient for this item.
$(this).children('.gradient').show();
}
else {
// Create a new gradient for this element
$(this).addClass('hasGradient').gradient({ from: 'dddddd', to: 'aaaaaa' });
}
},
function () {
// Mouse out (this doesn't always get called - must be a bug), hide the gradient.
$('.navbarItem').children(".gradient").hide();
}
);