Skip to content Skip to sidebar Skip to footer

Jquery Event.target Is_a_child_of(element)

Given element, a variable containing a javascript object/DOM element, how do I determine if the event.target is an element inside element or not? function(event){ // assume that

Solution 1:

You can also use .has()

if ($(element).has(e.target).length > 0){
//
}

Solution 2:

jQuery to the rescue:

if (jQuery.contains(element, e.target))

Post a Comment for "Jquery Event.target Is_a_child_of(element)"