Andy Evans
Andy Evans

Reputation: 7176

JQuery :: Capture hover event and change CSS on child div

I know I'm missing a small piece of this ... but for markup like this:

<a class="menusegment"><div>Link Text & Link Description</div></a>

I have the following jquery

$('a.menusegment').hover(function () {
    // insert code here
});

What I want to do is change the top border color of the div contained in 'a.menusegment'

Any help would be greatly appreciated.

Thanks!

Upvotes: 1

Views: 1443

Answers (3)

Ricky
Ricky

Reputation: 44

$(function(){
    $('a.menusegment').hover(function () {
        var thisNode = $(this);
        thisNode.children('div').css('border-top', '1px solid #f60');
    });
});

Upvotes: 3

Ricardo Bin
Ricardo Bin

Reputation: 887

If i understand your question... You dont need any kind of js

In CSS:

a.menusegment:hover div{
border-top:solid red 1px;
}

Upvotes: 2

Rafay
Rafay

Reputation: 31033

$('a.menusegment div').hover(function (e) {
    e.stopPropagation();

    // change color here
},
function(){
//code to execute on mouseleave
}
);

http://jsfiddle.net/3Bh5J/

Upvotes: 2

Related Questions