If you pass an object to Google Chrome's console.log()
that is not a primitive value like string or a number, it does not output that object's contents immediately. Probably due to some interprocess communication, there is some delay in actually getting the data from the object and outputting to the console. This will/can cause problems if you are immediately modifying the same object as you won't necessarily get the right thing displayed in the console.
One work-around is to only pass finished strings to console.log()
. Since strings are immutable, they will never get changed by anything else so you won't get deceived by console.log()
.
In your case, you are removing the DOM elements in the next line of code. Because of Chrome's timing weirdness, this removes the DOM elements before console.log()
can actually see what they are and output them. You could do something like this instead which makes the displayed string immediately and passes that string to console.log()
:
console.log($(this).find(' .buttons .cancel').toString());