mercredi 22 juin 2016

Why will my addClass not target only the current element?

When I add class Icon using the if statement it adds it to the correct h3 but also to any h3 elements above the correct one, even if the h3 above is 0. Icon will either be 0 or 1.

{ $('#accordion') .append($('<h3>') .html(Agency));  
        if (Icon == 1) {
            $('h3') .addClass('Icon');
        }    
        AccordionChild = $('<div>');                                                                        
        }
        AccordionChild.append("<div>") .html(ToolsList);
        $('#accordion').append(AccordionChild);
      });
    }

image

Aucun commentaire:

Enregistrer un commentaire