0

I have the following code:

$('body').on('click','#confirm_remove',function(){
  alert($(this).data('whattoremove'));
});

The #confirm_remove is a button id inside a bootstrap modal, who's data attribute (whattoremove) gets updated every time the modal opens - this is verified, but for some reason the data in the jQuery function has the same value on every click - this is the value of the first time it was clicked.

Any ideas on how to fix this.

1
  • 1
    Please share you HTML code. Commented Oct 22, 2017 at 13:24

1 Answer 1

1

try this:

$('#confirm_remove').click(function(){
  alert( $('#confirm_remove').attr('whattoremove') );
});
Sign up to request clarification or add additional context in comments.

1 Comment

While you may have solved this user's problem, code-only answers are not very helpful to users who come to this question in the future. Please edit your answer to explain why your code solves the original problem.

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.