Prevent click opening all elements using $this

Hi all

I have a hide and show working quite well, thanks to @PaulOB for helping me with this on a previous thread.

The problem is, everytime I click one link, all the hidden elements open. I need a way to only affect the current link I click. I think we need to use $this somehow, and stop all the links showing. Hope this makes sense.

Here is a fiddle of the problem.
I’d also like to swap the ‘Read More’ text to “Read Less” once opened.


Each <p class="results"> needs an ID (unique to each), first. Then each link to click needs something that can refer to its relevant results paragraph.



Thanks WolfShade. Adding a unique ID for each seems a little overkill, this is achievable without using a bunch of IDs. I’m sure. If you check out an old thread jQuery fiddle I was working on sometime back you’ll see that no IDs are used.

Is it possible we can do something like this using my velocity setup?


You are currently targetting everything with class=“results” where what you need to target is the element immediately following the one that triggered the event.

Thanks felgall, what do you suggest? Could you supply an example?

And do we need to use $(this) somewhere?


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.