This has got to be an easy one...
I have a list. I want to show the one element in each list item, with an option to see more (if there are any). Like this:
<li class="item">
<div class="elementToShow">Shown Element</div>
<div class="elementsToBeHidden">Hidden Element</div>
</li>
<li class="item">
<div class="elementToShow">Shown Element</div>
</li>
<li class="item">
<div class="elementToShow">Shown Element</div>
<div class="elementsToBeHidden">Hidden Element</div>
</li>
I then want to add a button in jQuery to expose the other elements:
$('.item).children('.elementsToBeHidden')
.wrapAll('<div class="hiddenElements"></div>');
$('<a class="hiddenElements"> See More </a>')
.appendTo($('.hiddenElements'))
.click(function() {
$('.elementsToBeHidden').slideToggle('slow');
});
This, though, groups all the hidden elements under the first list item.
What is missing if I want to show the first hidden element in the first item and the third in the third item?
With thanks in advance for any help.