1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to open accordion panel from an external link

Discussion in 'HTML & Website Design' started by columbaweb, Mar 6, 2013.

  1. #1
    I am new to jQuery and really stuck with it.

    I have a WordPress site with the posts in jQuery accordion and a link to latest posts on another page. I am trying to open the specific panel of an accordion using the external link.
    At the moment when you click on the link, you move to the appropriate page and panel, but the panel stays closed.

    Here is the code I am using for the accordion:

    <script type="text/javascript">
    $(document).ready(function() {Accordion();});

    function Accordion() {
    $('.accordion ul').hide();
    $('.accordion ul:first').show();
    $('.accordion li a:first').addClass('selected');

    $('.accordion li a').click(function(){
    $('.accordion li a').removeClass('selected');
    $(this).toggleClass('selected');
    });

    $('.accordion li a').click(
    function(event) {
    var checkElement = $(this).next();
    if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
    $('.accordion ul:visible').slideUp('normal');
    return false;
    }

    if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
    $('.accordion ul:visible').slideUp('normal');
    checkElement.slideDown('normal');
    return false;
    }
    }
    );
    }
    </script>

    Thank's for any help or suggestions.
     
    columbaweb, Mar 6, 2013 IP
  2. Forbidd3n

    Forbidd3n Well-Known Member

    Messages:
    262
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #2
    $('#link').click(function(){ $('#accordion').accordion({ active: 2 }); });
     
    Forbidd3n, Mar 6, 2013 IP
    ValentinMuller likes this.
  3. columbaweb

    columbaweb Greenhorn

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #3
    Forbidd3n, thanks a lot! you saved me :)
     
    columbaweb, Mar 6, 2013 IP
  4. Forbidd3n

    Forbidd3n Well-Known Member

    Messages:
    262
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #4
    No problem. Anytime.
     
    Forbidd3n, Mar 6, 2013 IP
  5. ValentinMuller

    ValentinMuller Member

    Messages:
    26
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    38
    #5
    thanks, that's what I was needing too.
     
    ValentinMuller, Apr 25, 2013 IP