Hello friends!
Suppose I have something similar to this HTML (this is not my exact HTML, rewritten to simplify):
<a onclick="ShowHide(); return false;" href="#">show/hide</a>
<div>
<div id="summary">Summary of info below</div>
<div id="enclosure" style="display:none;">Information</div>
</div>
<a onclick="ShowHide(); return false;" href="#">show/hide</a>
<div>
<div id="summary">Summary of info below</div>
<div id="enclosure" style="display:none;">Information</div>
</div>
<a onclick="ShowHide(); return false;" href="#">show/hide</a>
<div>
<div id="summary">Summary of info below</div>
<div id="enclosure" style="display:none;">Information</div>
</div>
<a onclick="ShowHide(); return false;" href="#">show/hide</a>
<div>
<div id="summary">Summary of info below</div>
<div id="enclosure" style="display:none;">Information</div>
</div>
These DIVS are full of information populated from a MSQL db. So the DIV names cannot be unique.
I have this jQuery code:
function ShowHide() {
$("#enclosure").animate({"height": "toggle"}, { duration: 500 });
$("#summary").toggle({"opacity":"0%"}, { duration: 200 });
};
This code actually works perfectly except for one major headache. When I click the 'hide/show' link on any of these - the only one that hides or shows is the first set.
After research I feel like I'll need to use the .parent() selector or (this) somewhere but I feel like I've tried every combination.
Any ideas? Thank you SO much.