OpenClose Neighbour-Links
Opens more-info on clicking a link and automatically hides all others.
HTML
<ul>
<li>short description
<a class="grey_button close" href="#">
<span class="more">read more</span>
<span class="hide">hide</span></a>
<div class="job_description">Here is more to read.</div>
</li>
<li>short description
<a class="grey_button close" href="#">
<span class="more">read more</span>
<span class="hide">hide</span></a>
<div class="job_description">Here is more to read.</div>
</li>
<li>short description
<a class="grey_button close" href="#">
<span class="more">read more</span>
<span class="hide">hide</span></a>
<div class="job_description">Here is more to read.</div>
</li>
<li>short description
<a class="grey_button close" href="#">
<span class="more">read more</span>
<span class="hide">hide</span></a>
<div class="job_description">Here is more to read.</div>
</li>
</ul>
CSS
.job_description { display: none; }
.grey_button.close span.hide,
.grey_button.open span.more { display: none; }
.grey_button.close span.more,
.grey_button.open span.hide { display: inline; }
JavaScript
$(document).ready(function() {
$('.grey_button.close').live('click', function() {
$('.grey_button.open').click();
$('.job_description');
$(this).siblings('.job_description').slideDown();
$(this).toggleClass('close open');
return false;
});
$('.grey_button.open').live('click', function() {
$('.job_description');
$(this).toggleClass('close open');
return false;
});
});