// 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'); });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter