I want to catch the click event on any elements of the page. But I can not catch a click on a specific page elements. See example https://jsfiddle.net/rdnf5m1f/
 $(function() {
        $(".profile").on( "click","a", function() {
            console.log(1);
          return false;
        });
        // below not work
        $("body").on( "click","*", function() {
            console.log(2);
        });
        $("body").click(function() {
            console.log(2);
        });
        $(window).click(function() {
            console.log(2);
        });
 });
Why?
Following what you need by "Capture all, Except some". Add a class 'nocapture' to the elements that you don't want to capture, and use the script:
jQuery('*:not(.nocapture)').on('click', function(e){
    e.stopPropagation();
    console.log('Element clicked', this); 
})
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With