// Normal Event $("#dataTable tbody tr").on("click", function() { console.log($(this).text()); }); // Delegate event to "#dataTable tbody" since "tr" elements don't exist yet $("#dataTable tbody").on("click", "tr", function() { console.log($(this).text()); }); // Delegate event to "document" since "#.bar.desktop" element does not exist yet $(document).on("click", ".bar.desktop", function() { $(this).toggleClass('open'); });