jQuery to toggle Read More link
-
Hi there, I’m hoping someone can help me out here as it will really make my day.
On my index page, all the posts are displayed in chronological order. When users click a post it simply expands and they rarely need to view the actual single post. This is all working well.
What I’m trying to do is toggle a read more link so that when the post expands, the Read More link dissapears and then reappears when the post shrinks again.
I’m no jQuery expert and my solution seems to affect all Read More links for all the posts on the index page, even though I’m calling it within The Loop.
I just want it to affect one post at a time. Nothing fancy.
Here is my code that says when .trigger is clicked, toggle the readMore element.
I guess I’m just calling it incorrectly. If anyone can help, that would be awesome.
<span class="readMore"><?php the_field('read_more'); ?></span> <script type="text/javascript"> $(".trigger").click(function () { $(".readMore").toggle(); }); </script>
- The topic ‘jQuery to toggle Read More link’ is closed to new replies.