So i have this situation
<div class='linkDiv'>
<a href='#' class='link'>
Click here
</a>
</div>
and when you click on the linkDiv i want to add the same class to .linkDiv and .link but only the ones clicked
$('.linkDiv').click(function(){
//some other code that works fine
//atm i have this
$(this).addClass('active');
$('.link', this).addClass('active');
});
How could i select both the clicked div and the child anchor of that div together?
I tried this:
$('.linkDiv, .link', this)
But it only selected .link
You can use find() with andSelf():