I'm trying to get the following working so I can make certain elements of a page reveal others on hover using jQuery. I'm trying to use the data attribute of the hover element to pick the revealed element.
I just can't seem to get this working. Or is there a better way to do this?
function setUpServiceHover(){
$( ".poster-banners__poster" ).each(function(i) {
$(this).hover(
function () {
$("#service_" + ($(this).data('target')).addClass('intro__service--show'));
$("#service_" + ($(this).data('target')).removeClass('intro__service--hidden'));
},
function () {
$("#service_" + ($(this).data('target')).addClass('intro__service--hidden'));
$("#service_" + ($(this).data('target')).removeClass('intro__service--show'));
})
});
}
setUpServiceHover();
Appreciate the help.
Thanks.