¿Por qué este trabajo:padres vs cercano
$('.button_30').click(function(){
$(this).closest('.portlet').find('.portlet_content').text("foo");
});
ninguna razón por qué no funciona:
$('.button_30').click(function(){
$(this).parent('.portlet').find('.portlet_content').text("foo");
});
donde el HTML se ve algo como esto:
<div class="portlet portlet_30">
<div class="portlet_header portlet_header_30">
header content here
</div>
<div class="portlet_sub_header portlet_sub_header_30">
<input type="text" class="textbox_30" />
</div>
<div class="portlet_content portlet_content_30">
results go here
</div>
<div class="portlet_footer portlet_footer_30">
<input type="button" class="button_30" />
</div>
</div>
<div class="portlet portlet_30">
<div class="portlet_header portlet_header_30">
header content here
</div>
<div class="portlet_sub_header portlet_sub_header_30">
<input type="text" class="textbox_30 />
</div>
<div class="portlet_content portlet_content_30">
results go here
</div>
<div class="portlet_footer portlet_footer_30">
<input type="button" class="button_30" />
</div>
</div>
porque '.portlet' no es el padre del' .button_30', '.portlet_footer' es el padre. –
Se compara con los padres aquí: https://api.jquery.com/closest/ –