jQuery: Detect update of HTML element

While I was working on fixing some Cucumber tests in a Rails project having Twitter Boostrap and the unobtrusive_flash gem, I was needing to see the update of the flash message in my application while the tests were running.

You can achive this with the following snippet:

When the div having the class unobtrusive-flash-container is updated, the text is logged in to the console of your browser.

Source: http://stackoverflow.com/a/4979828/1996540