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.
Written by Ion D. Filho
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Type check
Authors
iondrimba
11.64K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#