I have a jQuery toggler that I am fighting with. I can get it to toggle the visibility of multiple divs at once, but as soon as I implement the next() function, the only thing that toggles is the plus/minus portion of the script, not the visibility of the div. Anything stand out in this code?
This works, but toggles all divs instead of just the closes one:
jQuery(function(){
jQuery(".toggleText").click(function(){
jQuery(".hiddenText").slideToggle("fast");
jQuery(this).html(function(i,html) {
if (html.indexOf('More') != -1 ){
html = html.replace('More','Less');
} else {
html = html.replace('Less','More');
}
return html;
}).find('img').attr('src',function(i,src){
return (src.indexOf('plus.gif') != -1)? 'minus.gif' :'plus.gif';
});
});
});
This only toggles the more +/less - and not the .hiddenText div. (the only difference in these two is the addition of next() in the third line).
jQuery(function(){
jQuery(".toggleText").click(function(){
jQuery(this).next(".hiddenText").slideToggle("none");
jQuery(this).html(function(i,html) {
if (html.indexOf('More') != -1 ){
html = html.replace('More','Less');
} else {
html = html.replace('Less','More');
}
return html;
}).find('img').attr('src',function(i,src){
return (src.indexOf('plus.gif') != -1)? 'minus.gif' :'plus.gif';
});
});
});
Any ideas?
PS: I am using jQuery instead of the $ because of a conflict with the CMS this code lives. in.