Hello everyone,
I'm using the .css() function to modify the look of a <div> when you hover using the css hover selector. Unfortunately, the hover selector rule is overwritten once you click on a div because of the .css function.
Does anyone know of a simple way to solve the issue? A simple .hover() won't work because there's some logic that determines whether or not a menu item is selected (hence the css change).
Here's some code:
- $('div.click').hover (
function () {
//$(this).css({'color': '#6b7cbb'}); // Disabled for now
$('div.click').click(function(event){
var targetId = $(event.target).attr('target');
divId = $(this).attr('id');
if ( targetId != activeContent ) {
var targetDiv = $('#'+targetId)[0];
if ( targetDiv != null ) {
$('#' + activeContent).hide(100, function () {
$(targetDiv).slideDown(500);
if ($('div.active').css('background-color') != '#5367b0') {
$('div.active').css('background-color', '#5367b0');
}
});
if ( tempId != divId ) {
$(this).css('background-color', '#6476b8');
$(this).css('color', '#fff');
$('#' + tempId).css('background-color', '#efece9');
$('#' + tempId).css('color', '#6c6b68');
}
activeContent = targetId;
tempId = divId;
}
}
return false;
});
},
function () {
/* On mouse leave, change the color back */
/*$(this).css(
{
'color': '#6c6b68'
}
);
*/
}
);
Thanks,
Eggers