A div receives a new paragraph with every click, jQuery checks if there was a change in the DOM, the event is usually called but is returning the message:
UNDEFINED. Verification does not work with .size () and .lenght of jQuery v3.3.1 .
HTML:
<div class='mensagem-list'></div>
And jQuery:
<script>
$("body").on('DOMSubtreeModified', '.mensagem-list', function() {
window.alert( $('.p-list').size );
});
</script>
On the console every time you click the button, the date looks like this:
<div class='mensagem-list'>
<p class='p-list'>[mensagem exibida]</p>
<p class='p-list'>[mensagem exibida]</p>
</div>