Reputation: 539
I'm trying to create a function to open the last echoes. I do not really understand how I can do it without adding seven times. NEXT ()
When I click the onopen_close
button I need open a pelet_div
.
This is my HTML:
<div class="table_tr ">
<div class="w30 first"><input type="button" value="" class="open_close"/></div>
<div class="w120 first"><span>Medicid MI</span></div>
<div class="w120"><span>Income</span></div>
<div class="w120"><span>10/03/2014</span></div>
<div class="w170"><span>Payment-Cash</span></div>
<div class="w120"><span>-2616.00</span></div>
<div class="w120"><span> 10/ 000073</span></div>
<div class="w120"><span>12/004155</span></div>
<div class="pelet_div">
</div>
</div>
This is the jQuery code:
$(document).ready(function(){
$(".pelet_div").hide();
$(".open_close").show().click(function () {
clickedComponent = $(this);
$(this).closest('div').next().slideToggle(function(){
if($(this).is(':visible'))
clickedComponent.css("background-position","left top");
else
clickedComponent.css("background-position","left -14px");
});
});
});
Upvotes: 0
Views: 32
Reputation: 33870
Using siblings with a selector seem to do the trick :
$(this).closest('div').siblings('.pelet_div').slideToggle(...)
Upvotes: 1