User121212 User121212 - 1 year ago 139
HTML Question

how to find target is button in Jquery?

In document click event how to return if target is button element

if( != 'button')

Whether above code was correct ?

Answer Source

You may do only

$(document).click(function(e) {
  if ( $( e.currentTarget ).is( ":button" ) ) {
    // Do things

Why would you use :button instead of button?

Because that way you can detect if it's a <input type="button"> OR a <button> tag, aswell the other input types which render as buttons.
If you're unsure about using this selector, check the :button selector jQuery docs.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download