Let’s say you have two selectors like this:
$(".class1, .class2").click(function() {
$(this).hide();
});
It seems that $(this) refers to both selectors. Is there a way to only refer to one and not the other? (I dont mean just using .class1 or .class2 because I want it to refer to the element that is being clicked if there are multiple elements with those classes.)
I just realized that you could write out the same thing twice, but that’s not very nice:
$(".class1").click(function() {
$(this).hide();
$(.element).show();
});
$(".class2").click(function() {
$(.element).show();
});
1 Answer