I want to be able to reuse the same function many times on one page..
So here's some psuedo-code :
$(".read_more").click(function(){
$(this).parents().find(".hidden_text").slideToggle("fast")
});
The problem with this code, however, is that it targets every elem on the page matching .hidden_text. Is there a way to combine closest() with this? Or is there a better way to refactor this?
Update:
HTML:
<div class="grid_2">
<div class="read_more">
Click Me
</div>
</div>
<div class="grid_2">
<div id=".hidden_text">
Bagels are the most resourceful tools to the most legendary programmers.
</div>
</div>