JSFiddle - React, Tailwind, and code Playground

HTML

<div class="cartProduct" productId="2">
   <div class="names">Patatoes</div>
   <div class="units">5</div>
   This text is directly in the productId div, not in a child.
</div>

JavaScript

$('body').on('click','[productId]',function(event) {
   $("<p>Click!</p>").appendTo("body");
});