0

I have this fiddle: https://jsfiddle.net/ren8v32v/

What I want, is that the .underline div moves under the clicked .block div. The problem is, is when I click on one of the inner divs, JavaScript also sees the div above, so the animation is 'nullified'.

I was wondering if this situation knows a solution.

1 Answer 1

1

Just use e.stopPropagation() at the beginning of the event handler. This will prevent the event from bubbling up through the dom.

$('.block').click(function(e) {
    e.stopPropagation();
    ... stuff

Updated fiddle https://jsfiddle.net/ren8v32v/1/

Sign up to request clarification or add additional context in comments.

1 Comment

Aah, look at that! I was looking for such a function for a long time now. Thanks alot!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.