DEV Community

mhsohag11
mhsohag11

Posted on

Answer: Apply click method to outer div but not inner div [duplicate]

I think event.stopPropagation() method would be most useful solution.you only need to call it on the children of outer div:

$("#outer").on('click', function () { 
   alert("triggered");
}).children().on('click', function (e) {
    e.stopPropagation();
});

Also check this Solution.

Top comments (0)

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay