I’m trying to apply the following functionality to separate elements and leverage this functionality independently from individual calls:
$('body').find('.togged').hide().end().find('a.toggle').click(function() {
$('body').find('.togged').slideToggle();
//var elem = $('a.toggle');
if($(this).hasClass('open')){
$(this).removeClass('open');
$(this).addClass('closed');
$(this).text('[ + ]');
}else{
$(this).removeClass('closed');
$(this).addClass('open');
$(this).text('[ - ]');
}
});
What the code above does right now is simply slide a div with the class “togged” (funny class name, I know, but eh–the class names “open” and “closed” allow me to simply do some image stuff with the CSS).
Anyway, this happens whenever a link with the class “toggle” is clicked on. What I would like to do is somehow mold all this to activate ONLY the element(s) somehow indicated or implied to that link. So many something like “<a href=”#" title=“Toggle Element” id=“toggedN”>Click Here</a>" where ‘N’ would be the number appended to the “togged” divs I wish to be toggle-able.
Is there a way to do this? Maybe a better way than what I’ve described here?