Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Nov 2010
    Posts
    393
    Thanks
    48
    Thanked 1 Time in 1 Post

    JQuery Accordion Style Switch

    Hello,

    I've setup a JSFiddle here: Simple jQuery Accordion - JSFiddle

    What I am trying to do is, upon clicking on an 'a' tag, if it is not currently the 'Active' class, to remove the 'Active' class from anywhere else giving them the 'NonActive' class name and giving the clicked on the 'Active' class name.

    Thank you for any help in advanced.

    Best Regards,
    Tim

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Location
    Kansas, USA
    Posts
    487
    Thanks
    0
    Thanked 54 Times in 53 Posts
    I've updated your fiddle. Here's the pertinent part.
    Code:
    link.on('click', function(e) {
    
        e.preventDefault();
    
        var a = $(this).attr("href");
    
        $(a).slideDown('fast');
    
        //$(a).slideToggle('fast');
        $("#accordion div").not(a).slideUp('fast');
    
        if($(this).is(".NoneActive")){
            $("#accordion a.Active").toggleClass("Active NoneActive");
            $(this).toggleClass("NoneActive Active");
        }
        
    });
    I used .NoneActive instead of .NonActive since that's what you had in HTML and CSS already.

  • Users who have thanked kansel for this post:

    MrTIMarshall (03-09-2014)

  • #3
    Regular Coder
    Join Date
    Nov 2010
    Posts
    393
    Thanks
    48
    Thanked 1 Time in 1 Post
    Thank you Kansel, your help is very much appreciated and I am grateful for your time spent in modifying my JSFiddle and explaining what you did.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •