Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery hover/change css property help

I'm new to jQuery and I'm looking for a simple script (or maybe there's a simpler method) where if a user hovers over an element, another element's css property changes.

For example, hover over this image and "border-bottom" on another element changes color or something, etc. thanks

like image 480
Mike Avatar asked Aug 02 '10 19:08

Mike


2 Answers

use the hover property

$('#elementA').hover(function(){
    $('#elementB').addClass('active');
},function(){
    $('#elementB').removeClass('active');
});

then style the active class in your css

like image 64
wowo_999 Avatar answered Oct 13 '22 01:10

wowo_999


What have you tried so far?

Here is the jQuery documentation on hover. Basically, provide a selector to the object that you want to hover over (and leave, if you don't want a permanent effect). Then, inside the event's function, select the object that you want changed and update its CSS settings. (Or, if you have a class for it written, update to the new class.)

If you want to add some code that you have tried to write (update your post), I would be more than happy to help you with it.

like image 25
JasCav Avatar answered Oct 13 '22 01:10

JasCav