Try:
$elm.on('click', function(event) {
if (event.target == this){ //run code only when the clicked target is the current element.
//your code
}
}
Another solution is adding this code:
$elm.find("button").on('click',function(event){
return false;//prevent default and stop propagation.
//or event.stopPropagation();
});
//your code
$elm.on('click', function() {
To use .find
with selector, you may need to include jQuery