You can only do
$(document).click(function(e) { if ( $( e.currentTarget ).is( ":button" ) ) {
Why use :button instead of button ?
This way you can determine if there is a <input type="button"> OR a <button> , as well as other input types that appear as buttons.
If you are not sure about using this selector, select : jQuery docs button selector .
source share