How can swap the content within a div without affecting the other divs with the same class
I have a listing of items on the page and each one has a <div> with a description in it. There are two versions of each description, one short and one full length. I like the user to be able to swap between them by clicking the 'more' and 'close' links. I have started the script but need some help to perfect it. The problem with what I wrote is that it applies to all the divs on the page instead of the specific one that was clicked. What can I change to correct it?
The jQuery:
- $(document).ready(function() {
- $('div.desc > p.desc-full').hide();
- $('a.more').click(function() {
- $('div.desc > p.desc-trunc').slideUp('fast');
- $('div.desc > p.desc-full').slideDown('fast');
- });
- $('a.close').click(function() {
- $('div.desc > p.desc-full').slideUp('fast');
- $('div.desc > p.desc-trunc').slideDown('fast');
- });
- });
The HTML:
- <div class="art-desc">
- <p class="desc-trunc">Truncated version of text<a class='more' href='#'>more</a></p>
- <p class="desc-full">Full length version of text<a class='close' href='#'>close</a></p>
- </div>
Thanks