To give a simplified example, I've got the following block repeated on the page lots of times (it's dynamically generated):
<div class="box">
<div class="something1"></div>
<div class="something2">
<a class="mylink">My link</a>
</div>
</div>
单击后,我可以通过以下链接访问链接的父级:
$(".mylink").click(function() {
$(this).parents(".box").fadeOut("fast");
});
然而我需要得到那个特定家长的<div class="something1">
分.
Basically, can someone tell me how to refer to a higher-level sibling without being able to refer to it directly? Let's call it big brother. A direct reference to the big brother's class name would cause every instance of that element on the page to fade out - which is not the desired effect.
I've tried:
parents(".box .something1") ... no luck.
parents(".box > .something1") ... no luck.
siblings() ... no luck.
Anyone? Thanks.