I alter the text of a button based on the selection by the user.
$(".someClass").click(function() {
$("#someID_1").text($(this).prop("innerHTML"));
$("#someID_1").attr("data-value", $(this).data("value"));
someFunction("someID_1");
});
I then want to call a function someFunction
.
function someFunction(someID) {
console.log(parseInt($("#" + someID).data("value")))
if ( parseInt($("#" + someID).data("value")) !== 10 ) {
// do something
} else {
// do something else
}
}
Whats happening is that console.log
plots on the very first function call (thus, very first click) the data-value
of the selection. However, when I select something new and the function gets executed again, the data-value
plotted through the console.log
stays the same. Looking at the DOM
, the data-value
gets updated though.
Why is that?