I have a show/hide Jquery function in place on a multi-entry page which toggles the visibility of extended content for each entry. It works nicely, however, when a “more” link is clicked it toggles the extended content for all entries simultaneously. I need to adjust the Jquery function to target each entry individually.
The only method I can think of to achieve this is to have the Jquery function target EE’s {entry_id} parameter as part of the click event. This thread seems to imply that it would be possible to use the {entry_id} but I find I’m still struggling to figure out the syntax / implementation. Can anyone advise? Or set me straight if there is a better way?
The Jquery is as follows:
function showMore(){
$('.more').hide();
$('.morelink a').click(function(e) {
$('.more').slideToggle('slow');
$('.morelink a').toggleClass("less");
$(this).text($(this).text() == 'Less' ? 'More' : 'Less');
e.preventDefault();
});
}
$(document).ready(function(){
showMore();
});This essentially looks for the click of a text link (.morelink a) and slidetoggles a hidden div (.more) while also toggles the text of said link from “More” to “Less” depending on the state. Note that this function, along with all of my Jquery, is located in a separate template which gets embedded on page load.
The stripped down html in question is simply:
{exp:channel:entries channel=“x” limit"x"}
<div class=“content”>content</div>
<div class="more">more content</div>
<div class="morelink"><a href="#">More</a></div>
{/exp:channel:entries}Any and all guidance is GREATLY appreciated.