im trying to hide the sibling of an element but the sibling has the same class as the element itself
here is the jquery code and html code
<div class="a">this is the trigger</div>
<div class="a">this div is to be hidden</div>
$(document).ready(function(){
$(".a").click(function(){
$(this).html('this is triggered');
$(this).siblings(".a").hide();
});
});
i thought that the this woulg be able to do it for me
Note: for reasons these two divs(.a
)must be of the same class
also note the divs are repeated
I think all you need is next()
$(this).html('this is triggered');
$(this).next().hide();