Clicking on background div only

This is a way to trigger a function when user clicked/touched the background div without hitting it’s child elements.

$('#parentDiv').click(function(e) {
    var clicked = $(e.target);
    if(!clicked.hasClass('parentDivClass')) {
        // do function
    }
});

So the target of the event will be what was clicked. By using a jQuery selector we can do even more fine grain checking (especially useful for very complicated applications) before triggering the function.

 
1
Kudos
 
1
Kudos

Now read this

Building a Slack Bot in Golang

The Background # This blog post details the steps in which I’ve built my first Slack Bot with less than trivial functionality. It was created over a hackathon and was then released on open source as Pricelinelabs’s leaderboard project... Continue →