This is not a duplicate question. I've looked around stackoverflow and none of the following questions have worked for me.
jQuery stop child elements animate on hover of parent
How to have click event ONLY fire on parent DIV, not children?
I have a parent element .cover
and a single child element inside called .details-wrapper
When i hover over the child element of the parent, the parent hover is being triggered. This is how i want it to be (Sorry about editing);
Currently what i have tried (And failed) is using return false;
and stopPropagation
The image has position: relative
and top: 160px
so it comes out of the original .cover
wrapper
It's really weird because the way i hover ovre the element determines how the jquery works. Here's a gif showing that.
https://gyazo.com/7153f3b8d3a57d0cfbb6b8d7d56caf0a
The jQuery i'm using is:
$(".cover").not('.details-wrapper').hover(function(e) {
if (e.target === this) {
$(".cover").css("background","url(url1), url('"+cover._url+"')");
}
}, function() {
$(".cover").css("background","url('"+cover._url+"')");
});
I'm unsure how I can fix this so when i hover over the child element it stops the hover for the parent from triggering.
Just for further clarity, this doesnt work either:
$(".cover").hover(function(e) {
if (e.target === this) {
$(".cover").css("background","url(url1), url('"+cover._url+"')");
}
}, function() {
$(".cover").css("background","url('"+cover._url+"')");
});
$(".cover .details-wrapper").hover(function(e) {
e.stopPropagation();
});