Try this:
$('.student-box').hover( function(){
var div = $(this);
div.find('.student-info').css({
opacity: '0.8'
marginTop: '-20px',
height: '130%'
});
div.find('.onhover-ul').show();
}, function(){
var div = $(this);
div.find('.student-info').css({
opacity: '0.7',
marginTop: '75px',
height: '63%'
});
div.find('.onhover-ul').hide();
});
It doesn't matter that you called the hover()
method on a div, inside the callback you're still just saying 'select all elements with the class ...'
Inside the callback function, this
is the DOM element that actually triggered the event. So you can wrap this in jQuery and call methods on it.
Using the css()
method in this way though isn't advised, you're better off adding a class name and moving the styling to a style sheet, otherwise you've got presentation in your behaviour.