alt text

How to arrange the code so that when you click on any menu item, you delete a span with a cross and add a green check mark to the place of it, and that if you switch, it changes as expected. Only an open menu item should display a check mark.

$("h3:first").addClass("active"); $("p:not(:first)").hide(); $("h3").click(function () { $('.accordion').toggleClass('#two'); $(this).next("p").slideToggle("slow") .siblings("p:visible").slideUp("slow"); $(this).toggleClass("active"); $(this).siblings("h3").removeClass("active").addClass('h3 > span'); } 

    1 answer 1

    You have some kind of scary code, everything can be done much easier, it is enough to hang up an additional class to the highlighted menu item, respectively, tie this class to the appearance of elements with a cross and a check mark.

    • Tell me how to tie a class with elements? - sasha1
    • let's say .control {background: url ("cancel.png")} .active .control {background: url ("accept.png")} - velther