1

I have the following code:

<a id="clickme" href="#">
    <span>Text for link goes here</span>
    <button id="deleteme">X</div>
</a>

And the following javascript:

$("body").on('click', "#clickme", function(e) {
  //stuff here
});


$("body").on('click', "#deleteme", function(e) {
  //stuff here
});

How do I make it so that when I click #deleteme the click event for #clickme does not run?

1 Answer 1

3

Use stopPropagation

$("body").on('click', "#deleteme", function(e) {
  e.stopPropagation();
});
Sign up to request clarification or add additional context in comments.

Comments

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.