How would i go about showing the closest paragraph element to a unique link with jQuery?
- by Nike
The title is a bit rusty, sorry about that.
Now let me explain what i'm trying to do.
I have a few listed items, like this:
<li>
<a id="toggle" class="0"><h4>ämne<small>2010-04-17 kl 12:54</small></h4></a>
<p id="meddel" class="0">text</p>
</li>
<li class='odd'>
<a id="toggle" class="1"><h4>test<small>2010-04-17 kl 15:01</small></h4></a>
<p id="meddel" class="1">test meddelande :) [a]http://youtube.com[/a]</p>
</li>
The function i'm trying to achieve, is that when a user clicks a "toggle" link (the h4 text), i want the paragraph element below it to fade in. I thought of the idea of giving both the toggle link and the paragraph the same class, and then somehow make it get the paragraph with the same class as the toggle link clicked, and show it? But i'm not entirely sure how to do that either, and tbh, it doesn't sound like the greatest idea, but maybe that's the only way? I don't know...
Is there some way to just simply get the nearest paragraph (below the link) with the id "meddel" and fade it in? That sounds a bit easier...
I hope you can at least give me a few hints.
Thanks in advance,
-Nike