Reputation: 271
$pageslide.click(function(e) {
e.stopPropagation();
});
That prevents the #pageslide ID or Class from sliding if clicked, how do i exclude certain elements from being prevented, in this case i want to exclude <a></a>
or <li></li>
. Thanks in advance .
Upvotes: 1
Views: 178
Reputation: 144689
.target
property of the event object refers to the target of the event, you can read this property:
$pageslide.click(function(e) {
if ( $.inArray(e.target.localName, ['li', 'a']) < 0 ) {
e.stopPropagation();
}
});
Or use .closest()
method:
if ( $(e.target).closest('a').length === 0 ) {
e.stopPropagation();
}
Upvotes: 2
Reputation: 1848
Use jQuery's filter method.
$pageslide.filter('a li').click(function(e) {
e.stopPropagation();
});
Upvotes: 2