Skip to content Skip to sidebar Skip to footer

How To Assign Different Behavior To Parent And Child Elements When Child Is Hovering On Top Of Parent?

Long story short Please see the demo here. I have several div.story-in-myworks inside each div.story-in-myworks, there is a div.pageimage-div-overlay that controls the overlay over

Solution 1:

The link below describes how to identify the origin of the click event and execute accordingly.

Link

This piece of code seems to work, though I haven't found out why it triggers twice on first load.

$(".story-in-myworks").mouseenter(function(e){
    var currentStory = $(this);

    $(this).click(function(e){
        if ($(e.target).hasClass('pageimage-div-overlay'))
            alert('test');

        if ($(e.target).hasClass('btn-storysetting')){
            alert('test2');

        }
    });
});

Post a Comment for "How To Assign Different Behavior To Parent And Child Elements When Child Is Hovering On Top Of Parent?"