Reputation: 860
I want to select #one, #two and the siblings of #two. Is there a more elegant solution that what I have?
$('#one, #two').click(function(e){
e.stopPropagation();
});
$('#two').siblings().click(function(e){
e.stopPropagation();
});
Upvotes: 2
Views: 302
Reputation: 9027
$("#one, #parentIdOfTwo > *").click(function(e) {
e.stopPropagation();
});
Lot faster, too.
Upvotes: 2
Reputation: 69905
Try this. Take a look I am using andSelf
which add the previous set of elements on the stack to the current set, really helpful in your case here.
$('#one').add($('#two').siblings().andSelf()).click(function(e){
e.stopPropagation();
});
Upvotes: 1
Reputation: 149534
You could use:
$('#one, #two').add($('#two').siblings()).click(function(event) {
event.stopPropagation();
});
…or:
$('#one').add($('#two').parent().children()).click(function(event) {
event.stopPropagation();
});
Upvotes: 0
Reputation: 148524
$('#one, #two').add($('#two').siblings()).click(function(e){
e.stopPropagation();
});
Upvotes: 0