mew6tg
Last Updated: February 25, 2016
·
7.937K
· iondrimba
178548

How to check the element type of an event target with jQuery

If you have a click event attached to a container (ex: table row, div ) but inside the container you have a button that will perform a different click action you can check the event.target of the container to see if the element clicked was a button type.

container.click(function(evt) {
    var isButton = $(evt.target).is(":button");

    if(isButton) {
      //perform different action
   }

});

This verification applies also to elements like :hidden , :submit, :checkbox, :radio and so on.

Say Thanks
Respond