Reputation: 717
ok, Im going to pass on submitting how I would do this...because I dont want a patch to an otherwise crappy piece of code. Heres what Im trying to do: I use php to output some divs. A corresponding set of divs is generated with the first divs. The whole idea is that when the first div is clicked, the corresponding div slides down. My attempts at this so far have been unsuccessful. Im guessing the id is going to have to correspond with the class of the other div or something to that affect. I've been baking on this one for awhile. Any help is really appreciated!
Upvotes: 0
Views: 50
Reputation: 2471
To start with, go with this structure:
<div class="main" rel="foo">Content</div>
<div class="main" rel="foo2">Content 3</div>
<div class="main" rel="foo3">Content war</div>
<div id="foo">Content</div>
<div id="foo2">Content</div>
<div id="foo3">Content</div>
And now, you can use a simple jQuery:
$(document).ready(function() {
$('.main').click(function() {
var opener = $(this).attr('rel');
$('#' + opener).slideToggle();
});
});
Upvotes: 1