This script currently serves on a side accordion menu. When the img is pressed, it removes and adds the class of category on the accordion, making that category’s links disappear.
Is there any method of having it apply to every div in the accordion, as opposed to just the one being pressed? Thanks.
(function(){
jQuery('a.navToggle').bind('click',function(){
var id = jQuery(this).attr('id');
if(jQuery(this).find('img').attr('src').indexOf('minus') != -1){
jQuery('div[id*=subnav-'+id+']').removeClass('expanded').addClass('collapsed');
jQuery(this).find('img').attr('src','lnav-plus.png');
} else {
//jQuery('div[id*=subnav-]').removeClass('expanded').addClass('collapsed');
jQuery('div[id*=subnav-'+id+']').removeClass('collapsed').addClass('expanded');
jQuery(this).find('img').attr('src','lnav-minus.png');
}
Instead of using
jQuery(this).find('img')orjQuery(this).attr('id')to find the clicked item, use a jQuery selector that finds all objects of a certain type in your accordion.For example:
jQuery('#accordion img')will select each image tag inside an accordion.As a side note, its advisable to use a class selector to find items like this!
If you post the rest of your code, I may be able to provide more insight.